ID:               45498
 Updated by:       [EMAIL PROTECTED]
 Reported By:      pager at marck dot us
 Status:           Bogus
 Bug Type:         Date/time related
 Operating System: Windows XP Home
 PHP Version:      5.2.6
 New Comment:

That's because PHP can calculate the date/time parameters for you, but
it can't touch the timezone that the OS uses internally as this is not
part of the struct that's passed to the system's strftime() call. Just
use date() and forget about strftime().


Previous Comments:
------------------------------------------------------------------------

[2008-07-13 11:00:51] pager at marck dot us

strftime is obeying the script setting for time format strings, and the
OS for time zone format strings.

How is that not a bug?

One or the other has to be wrong.

My example reports 06:21 Central Daylight Time when it's 05:21 Central
Daylight Time for that combination of settings. How is that ever correct
behavior?

------------------------------------------------------------------------

[2008-07-13 10:48:17] [EMAIL PROTECTED]

This is not a bug - strftime() uses the Operating System timezone
information which applications can not override. You want the date()
function to handle this correctly. The date() function does not rely on
the Operating System for any formatting.

------------------------------------------------------------------------

[2008-07-13 10:24:08] pager at marck dot us

Description:
------------
strftime is not showing the correct time zone as set by
date_default_timezone_set

Please note strftime reflects the correct time for the new time zone
setting, but not the correct time zone.

Reproduce code:
---------------
<?php
  
 error_reporting(E_ALL);

 $before = strftime('%H:%M %z');
  
 date_default_timezone_set('America/New_York');

 $after = strftime('%H:%M %z');
  
 echo("date('e'): ". date('e'). ", strftime('%z'): ". strftime('%z'));

 echo ", strftime('%H:%M %z') before: $before, strftime('%H:%M %z')
after: $after";
  
?> 

Expected result:
----------------
date('e'): America/New_York, strftime('%z'): Eastern Daylight Time,
strftime('%H:%M %z') before: 05:21 Eastern Daylight Time,
strftime('%H:%M %z') after: 06:21 Eastern Daylight Time

Actual result:
--------------
date('e'): America/New_York, strftime('%z'): Central Daylight Time,
strftime('%H:%M %z') before: 05:21 Central Daylight Time,
strftime('%H:%M %z') after: 06:21 Central Daylight Time

// note: on my setup Central Daylight Time would be expected if 
date_default_timezone_set had not been used


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=45498&edit=1

Reply via email to