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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 21 2025 04:12:38
Script start
Timing: Jan 21 2025 04:12:38
Module start 'layout'
Timing: Jan 21 2025 04:12:38
Module start 'content'
Timing: Jan 21 2025 04:12:39
Module end 'content'
Timing: Jan 21 2025 04:12:39
Script end

Main resources:

Total runtime0.9637 sec
Peak memory usage4,096.0000 KB
Database Queries55

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0074 587.9453151.2109
Module start 'layout' 0.00740.0033 739.156336.6484
Module start 'content' 0.01070.9520 775.8047542.0703
Module end 'content' 0.96270.0010 1,317.875011.8438
Script end 0.9637  1,329.7188 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.3377160.0002
Check MTime0.00120.1254160.0001
Mysql Total
Database connection0.00140.149910.0014
Mysqli_queries0.898993.2711550.0163
Looping result0.00050.0538530.0000
Template Total0.927896.320.4639
Template load0.00210.212820.0010
Template processing0.925896.064320.4629
Template load and register function0.00010.010110.0001
states
state_id_array0.00140.148410.0014
state_identifier_array0.00100.102720.0005
Override
Cache load0.00160.1676340.0000
Sytem overhead
Fetch class attribute can translate value0.00130.138110.0013
Fetch class attribute name0.00160.164740.0004
XML
Image XML parsing0.00070.069410.0007
class_abstraction
Instantiating content class attribute0.00000.002160.0000
General
dbfile0.00270.2798180.0001
String conversion0.00000.001040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 29
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs