[development] problem with custom date and timezones

Jamie Holly hovercrafter at earthlink.net
Fri Jul 17 11:54:52 UTC 2009


The date you are setting is in the GMT timezone. When you use format_date, it will add the timezone offset to that date, which is why you're getting the different dates. To get around that do this set 'custom' for format_date's second argument then the third argument is the pattern. The forth argument is the timezone offset. Set that to 0 and it won't calculate an offset (leave it as null and it will use Drupal's offset variable, which you set in admin). 

format_date($node->data_assentament,'custom', 'd-m-Y H:i',0)

Jamie Holly
http://www.intoxination.net 
http://www.hollyit.net



Lluís wrote:
> Making some research my problem is with format date:
>
> $node->data_assentament -> 1247781600
> date("d-m-Y H:i", $node->data_assentament) -> 17-07-2009 00:00
> format_date($node->data_assentament,'medium') -> Dij, 07/16/2009 - 22:00
>
> (I need the date in dd/mm/YYYY format)
>
> Should I avoid format_date() or there is a better way to solve this?
>
>
>   


More information about the development mailing list