[PHP] stftime differences on Windows/Linux platforms
Hi All, I'm experiencing some differences in in the return values of strftime on Windows Linux platforms on PHP 5.2.1. I've knocked up a test case to demonstrate the bug: ?php $UNIX_TIME = mktime(0,0,0,5,31,2008); echo Time Made for 31-05-2008: $UNIX_TIME\n; echo Expected Time for 31-05-2008: 1212188400\n; echo Formated generated: . strftime(%d-%m-%Y, $UNIX_TIME) . \n; echo Formated expected: . strftime(%d-%m-%Y, 1212188400) . \n; echo Difference between expected and generated: . ($UNIX_TIME - 1212188400); echo \n\n; ? OUTPUT DEVELOPMENT: C:\php -e c:\test.php Time Made for 31-05-2008: 1212188400 Expected Time for 31-05-2008: 1212188400 Formated generated:31-05-2008 Formated expected: 31-05-2008 Difference between expected and generated: 0 OUTPUT PRODUCTION: Time Made for 31-05-2008: 1212192000 Expected Time for 31-05-2008: 1212188400 Formated generated:31-05-2008 Formated expected: 30-05-2008 Difference between expected and generated: 3600 Development Config: PHP Version 5.2.1 PHP API 20041225 PHP Extension 20060613 Zend Extension 220060519 Production Config: PHP Version 5.2.1 Build Date Apr 25 2007 18:04:12 PHP API 20041225 PHP Extension 20060613 Zend Extension 220060519 Am I missing something obvious here? Any help gratefully received. Cheers, Neil. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] stftime differences on Windows/Linux platforms
On 06/11/2007, Neil Saunders [EMAIL PROTECTED] wrote: Hi All, I'm experiencing some differences in in the return values of strftime on Windows Linux platforms on PHP 5.2.1. I've knocked up a test case to demonstrate the bug: ?php $UNIX_TIME = mktime(0,0,0,5,31,2008); echo Time Made for 31-05-2008: $UNIX_TIME\n; echo Expected Time for 31-05-2008: 1212188400\n; echo Formated generated: . strftime(%d-%m-%Y, $UNIX_TIME) . \n; echo Formated expected: . strftime(%d-%m-%Y, 1212188400) . \n; echo Difference between expected and generated: . ($UNIX_TIME - 1212188400); echo \n\n; ? OUTPUT DEVELOPMENT: C:\php -e c:\test.php Time Made for 31-05-2008: 1212188400 Expected Time for 31-05-2008: 1212188400 Formated generated:31-05-2008 Formated expected: 31-05-2008 Difference between expected and generated: 0 OUTPUT PRODUCTION: Time Made for 31-05-2008: 1212192000 Expected Time for 31-05-2008: 1212188400 Formated generated:31-05-2008 Formated expected: 30-05-2008 Difference between expected and generated: 3600 Development Config: PHP Version 5.2.1 PHP API 20041225 PHP Extension 20060613 Zend Extension 220060519 Production Config: PHP Version 5.2.1 Build Date Apr 25 2007 18:04:12 PHP API 20041225 PHP Extension 20060613 Zend Extension 220060519 Am I missing something obvious here? Any help gratefully received. Well, either the clocks on your dev and production servers are exactly 6 hours out or there's a difference in their locale settings such that one thinks it's in a timezone 6 hours ahead of the other. -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] stftime differences on Windows/Linux platforms
Hi Robin, Thanks for your reply. The times are exactly synchronized. I'm looking at the date section in the output of phpinfo(), and get the following: Development: D:\Documents and Settings\neil.saundersdate The current date is: 06/11/2007 D:\Documents and Settings\neil.saunderstime The current time is: 12:47:06.46 date date/time support enabled Timezone Database Version 2006.16 Timezone Database internal Default timezoneEurope/London Directive Local Value Master Value date.default_latitude 31.7667 31.7667 date.default_longitude 35.2333 35.2333 date.sunrise_zenith 90.58 90.58 date.sunset_zenith 90.58 90.58 date.timezone no valueno value Production: [~]# date Tue Nov 6 12:49:25 GMT 2007 date date/time support enabled Timezone Database Version 2006.16 Timezone Database internal Default timezoneUTC Directive Local Value Master Value date.default_latitude 31.7667 31.7667 date.default_longitude 35.2333 35.2333 date.sunrise_zenith 90.58 90.58 date.sunset_zenith 90.58 90.58 date.timezone no valueno value Although the timezones are different, my understanding is the UTC is a synonym for GMT, which is based in London. This appears to be confirmed by looking at the default latitudes and longitudes and they match up. Either way, setting the timezone to Europe/London in production fixed the issue. Thanks again for your help. Cheers, Neil. On Nov 6, 2007 12:01 PM, Robin Vickery [EMAIL PROTECTED] wrote: On 06/11/2007, Neil Saunders [EMAIL PROTECTED] wrote: Hi All, I'm experiencing some differences in in the return values of strftime on Windows Linux platforms on PHP 5.2.1. I've knocked up a test case to demonstrate the bug: ?php $UNIX_TIME = mktime(0,0,0,5,31,2008); echo Time Made for 31-05-2008: $UNIX_TIME\n; echo Expected Time for 31-05-2008: 1212188400\n; echo Formated generated: . strftime(%d-%m-%Y, $UNIX_TIME) . \n; echo Formated expected: . strftime(%d-%m-%Y, 1212188400) . \n; echo Difference between expected and generated: . ($UNIX_TIME - 1212188400); echo \n\n; ? OUTPUT DEVELOPMENT: C:\php -e c:\test.php Time Made for 31-05-2008: 1212188400 Expected Time for 31-05-2008: 1212188400 Formated generated:31-05-2008 Formated expected: 31-05-2008 Difference between expected and generated: 0 OUTPUT PRODUCTION: Time Made for 31-05-2008: 1212192000 Expected Time for 31-05-2008: 1212188400 Formated generated:31-05-2008 Formated expected: 30-05-2008 Difference between expected and generated: 3600 Development Config: PHP Version 5.2.1 PHP API 20041225 PHP Extension 20060613 Zend Extension 220060519 Production Config: PHP Version 5.2.1 Build Date Apr 25 2007 18:04:12 PHP API 20041225 PHP Extension 20060613 Zend Extension 220060519 Am I missing something obvious here? Any help gratefully received. Well, either the clocks on your dev and production servers are exactly 6 hours out or there's a difference in their locale settings such that one thinks it's in a timezone 6 hours ahead of the other. -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] stftime differences on Windows/Linux platforms
On 06/11/2007, Neil Saunders [EMAIL PROTECTED] wrote: Hi Robin, Thanks for your reply. The times are exactly synchronized. I'm looking at the date section in the output of phpinfo(), and get the following: Development Default timezoneEurope/London Production: Default timezoneUTC Although the timezones are different, my understanding is the UTC is a synonym for GMT, which is based in London. This appears to be confirmed by looking at the default latitudes and longitudes and they match up. Either way, setting the timezone to Europe/London in production fixed the issue. Thanks again for your help. Aye, sorry. I don't know what I was thinking, when I said six hours; the difference is of course 60 minutes. The Dev server is in Europe/London, which is adjusted by an hour during British Summer Time. The production server was using UTC. Because the date (31 May) was within BST, there was an hour difference between the two. -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php