#47513 [Com]: when using date, H shows 01 instead of 00
ID: 47513 Comment by: usrhlp at yahoo dot com Reported By: usrhlp at yahoo dot com Status: Open Bug Type: Date/time related Operating System: Debian PHP Version: 5.2.8 New Comment: Thank you, GMDATE has fixed the issue!! Please close this bug as erroneous. Previous Comments: [2009-02-27 21:59:07] shaunspiller at gmail dot com It's the time zone on your machine. The number "5" refers to the time January 1 1970 @ 00:00:05 UTC, which date() will format as something different if you're in CET, etc. Use the format codes 'O' or 'P' to show the timezone offset. If you want it always fixed at UTC, use gmdate() instead of date(). Or use date_default_timezone_set first. E.g., if (version_compare(PHP_VERSION, '5.1.0', '>=')) { date_default_timezone_set('UTC'); } [2009-02-26 23:07:57] usrhlp at yahoo dot com I just tried it on another server I have with php 5.2.6 and i get this result 18:00.01 18:00.10 18:01.40 18:16.40 20:46.40 21:46.40 07:46.40 12:46.40 That has totally thrown me off. [2009-02-26 22:59:30] usrhlp at yahoo dot com Description: I am probably doing something wrong but I cannot for the life of me figure out what it is. I am trying to convert a small number to 24 hour time format. For example I'm parsing the number 5 through the date function and I am receiving the answer 01:00.05 I checked the PHP documentation and it shows as this for date() H 24-hour format of an hour with leading zeros00 through 23 According to the documentation 00 is a possible output of the H formatting within date and should be what is coming out. Reproduce code: --- echo(date("H:i.s" ,1)); echo(date("H:i.s" ,10)); echo(date("H:i.s" ,100)); echo(date("H:i.s" ,1000)); echo(date("H:i.s" ,1)); echo(date("H:i.s" ,10)); echo(date("H:i.s" ,100)); echo(date("H:i.s" ,1000)); Expected result: time: 00:00.01 time: 00:00.10 time: 00:01.40 time: 00:16.40 time: 03:46.40 time: 04:46.40 time: 14:46.40 time: 18:46.40 Actual result: -- time: 01:00.01 time: 01:00.10 time: 01:01.40 time: 01:16.40 time: 03:46.40 time: 04:46.40 time: 14:46.40 time: 18:46.40 -- Edit this bug report at http://bugs.php.net/?id=47513&edit=1
#47513 [Com]: when using date, H shows 01 instead of 00
ID: 47513 Comment by: shaunspiller at gmail dot com Reported By: usrhlp at yahoo dot com Status: Open Bug Type: Date/time related Operating System: Debian PHP Version: 5.2.8 New Comment: It's the time zone on your machine. The number "5" refers to the time January 1 1970 @ 00:00:05 UTC, which date() will format as something different if you're in CET, etc. Use the format codes 'O' or 'P' to show the timezone offset. If you want it always fixed at UTC, use gmdate() instead of date(). Or use date_default_timezone_set first. E.g., if (version_compare(PHP_VERSION, '5.1.0', '>=')) { date_default_timezone_set('UTC'); } Previous Comments: [2009-02-26 23:07:57] usrhlp at yahoo dot com I just tried it on another server I have with php 5.2.6 and i get this result 18:00.01 18:00.10 18:01.40 18:16.40 20:46.40 21:46.40 07:46.40 12:46.40 That has totally thrown me off. [2009-02-26 22:59:30] usrhlp at yahoo dot com Description: I am probably doing something wrong but I cannot for the life of me figure out what it is. I am trying to convert a small number to 24 hour time format. For example I'm parsing the number 5 through the date function and I am receiving the answer 01:00.05 I checked the PHP documentation and it shows as this for date() H 24-hour format of an hour with leading zeros00 through 23 According to the documentation 00 is a possible output of the H formatting within date and should be what is coming out. Reproduce code: --- echo(date("H:i.s" ,1)); echo(date("H:i.s" ,10)); echo(date("H:i.s" ,100)); echo(date("H:i.s" ,1000)); echo(date("H:i.s" ,1)); echo(date("H:i.s" ,10)); echo(date("H:i.s" ,100)); echo(date("H:i.s" ,1000)); Expected result: time: 00:00.01 time: 00:00.10 time: 00:01.40 time: 00:16.40 time: 03:46.40 time: 04:46.40 time: 14:46.40 time: 18:46.40 Actual result: -- time: 01:00.01 time: 01:00.10 time: 01:01.40 time: 01:16.40 time: 03:46.40 time: 04:46.40 time: 14:46.40 time: 18:46.40 -- Edit this bug report at http://bugs.php.net/?id=47513&edit=1
#47513 [Com]: when using date, H shows 01 instead of 00
ID: 47513 Comment by: usrhlp at yahoo dot com Reported By: usrhlp at yahoo dot com Status: Open Bug Type: Date/time related Operating System: Debian PHP Version: 5.2.8 New Comment: I just tried it on another server I have with php 5.2.6 and i get this result 18:00.01 18:00.10 18:01.40 18:16.40 20:46.40 21:46.40 07:46.40 12:46.40 That has totally thrown me off. Previous Comments: [2009-02-26 22:59:30] usrhlp at yahoo dot com Description: I am probably doing something wrong but I cannot for the life of me figure out what it is. I am trying to convert a small number to 24 hour time format. For example I'm parsing the number 5 through the date function and I am receiving the answer 01:00.05 I checked the PHP documentation and it shows as this for date() H 24-hour format of an hour with leading zeros00 through 23 According to the documentation 00 is a possible output of the H formatting within date and should be what is coming out. Reproduce code: --- echo(date("H:i.s" ,1)); echo(date("H:i.s" ,10)); echo(date("H:i.s" ,100)); echo(date("H:i.s" ,1000)); echo(date("H:i.s" ,1)); echo(date("H:i.s" ,10)); echo(date("H:i.s" ,100)); echo(date("H:i.s" ,1000)); Expected result: time: 00:00.01 time: 00:00.10 time: 00:01.40 time: 00:16.40 time: 03:46.40 time: 04:46.40 time: 14:46.40 time: 18:46.40 Actual result: -- time: 01:00.01 time: 01:00.10 time: 01:01.40 time: 01:16.40 time: 03:46.40 time: 04:46.40 time: 14:46.40 time: 18:46.40 -- Edit this bug report at http://bugs.php.net/?id=47513&edit=1