Forums / Developer / possible bug in datetime formatting

possible bug in datetime formatting

Author Message

Marko Žmak

Wednesday 19 July 2006 12:27:39 pm

I encountered a problem (possibly bug) with date formating...

I have a timestamp of $t=1153267200 which is equal to:

Wednesday, July 19th 2006, 0:00:00 (GMT)
or
Wednesday, July 19th 2006, 1:00:00 (GMT +1)

This can be checked at http://www.4webhelp.net/us/timestamp.php .
But when I try to output this:

{$t|l10n( 'shortdatetime' )}

I get:

19.07.2006. 02:00

I'm sure that my server is in (GMT +1) zone because the output of:

{datetime('custom', '%O')}

is:

+0100

and so the time in the last date should be 01:00 and not 02:00.

It seems like there's one hour too much. Why is this happening? Is it a bug?

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Marko Žmak

Thursday 20 July 2006 8:20:09 am

I just made a script to verify time in PHP and this is what I got:

Sistemi timestamp: time() = 1153408523
Into date/time: gmdate("M d Y H:i:s", 1153408523) = Jul 20 2006 15:15:23
Into local date/time: date("M d Y H:i:s", 1153408523) = Jul 20 2006 17:15:23
Time zone: date("O", 1153408523) = +0200

But in eZ (as I mentioned) I get the time zone "+0100". Why? Where from is the time zone derived in eZ?

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Marko Žmak

Monday 24 July 2006 6:12:27 am

I solved this one. The problem was in the "dayligh saving" change of time also known as CEST.
Regarding to this, here's a suggestion to everyone. I was trying to get the today's date (with 00:00h) from the currentdate() function like this:

{def $today_date=currentdate() $one_hour=3600 $one_day=mul(24,$one_hour)}
{set today_date=mul(floor(div($today_date,$one_day)),$one_day)}

This is not correct. You should add this line after the above code:

{set today_date=sub($today_date,mul(datetime('custom', '%O'),$one_hour))}

So that the time is adapted to the apropriate time zone.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth