ddd119 Posted March 20, 2008 Share Posted March 20, 2008 Here is the code: print date("Y m d H",1099198800) ."\n"; print date("Y m d H",1099202400) ."\n"; and here is the output: 2004 10 31 01 2004 10 31 01 I believe it is not rigth! I can reproduce the result on a couple PHP installations between PHP 4.2 and PHP 5.2; I cannot reproduce it with another year, month or day. Help Please ? Quote Link to comment https://forums.phpfreaks.com/topic/97116-date-function-error/ Share on other sites More sharing options...
BlueSkyIS Posted March 20, 2008 Share Posted March 20, 2008 my output: 2004 10 30 23 2004 10 31 00 Quote Link to comment https://forums.phpfreaks.com/topic/97116-date-function-error/#findComment-496916 Share on other sites More sharing options...
ddd119 Posted March 20, 2008 Author Share Posted March 20, 2008 Yours is even worse !... Quote Link to comment https://forums.phpfreaks.com/topic/97116-date-function-error/#findComment-496920 Share on other sites More sharing options...
BlueSkyIS Posted March 20, 2008 Share Posted March 20, 2008 mine appears to be right on. go backwards: echo mktime(23,0,0,10,30,2004)."<BR>"; echo mktime(00,0,0,10,31,2004)."<BR>"; even better: <? echo mktime(23,0,0,10,30,2004)."<BR>"; echo mktime(00,0,0,10,31,2004)."<BR>"; print date("Y m d H",mktime(23,0,0,10,30,2004)) ."<BR>"; print date("Y m d H",mktime(00,0,0,10,31,2004)) ."<BR>"; ?> output: 1099198800 1099202400 2004 10 30 23 2004 10 31 00 Quote Link to comment https://forums.phpfreaks.com/topic/97116-date-function-error/#findComment-496923 Share on other sites More sharing options...
ddd119 Posted March 20, 2008 Author Share Posted March 20, 2008 lokk at this: <?php print date("Y m d H",1099198800) ."\n"; print date("Y m d H",1099202400) ."\n"; print mktime(01,0,0,10,31,2004) ."\n"; ?> and the output is: 2004 10 31 01 2004 10 31 01 1099198800 so the second line is wrong. You tried with another time and is working ok. As I said, any other time seems ok. Quote Link to comment https://forums.phpfreaks.com/topic/97116-date-function-error/#findComment-496944 Share on other sites More sharing options...
BlueSkyIS Posted March 20, 2008 Share Posted March 20, 2008 my output: 2004 10 30 23 2004 10 31 00 1099206000 are you using windows? my second example used the exact same times you used, 1099198800 and 1099202400. here, it's changed to make it better: <? echo mktime(23,0,0,10,30,2004)."<BR>"; echo mktime(00,0,0,10,31,2004)."<BR>"; print date("Y m d H",1099198800) ."<BR>"; print date("Y m d H",1099202400) ."<BR>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/97116-date-function-error/#findComment-496950 Share on other sites More sharing options...
wildteen88 Posted March 20, 2008 Share Posted March 20, 2008 date/mksir will generate a date based on the servers timezone. You can use date_default_timezone_set function (not available for php4) to use a different timezone. This is why everyones results will be different to yours ddd119 Quote Link to comment https://forums.phpfreaks.com/topic/97116-date-function-error/#findComment-496956 Share on other sites More sharing options...
BlueSkyIS Posted March 20, 2008 Share Posted March 20, 2008 i don't think that has anything to do with it. he's getting nonsense displays for standard timestamps. what i get here and what he gets in Zimbabwe should be exactly the same. here's an idea: have you tried echo instead of print? Quote Link to comment https://forums.phpfreaks.com/topic/97116-date-function-error/#findComment-496959 Share on other sites More sharing options...
ddd119 Posted March 20, 2008 Author Share Posted March 20, 2008 thanks, but the point was that i am getting the same date from 2 different numbers !! and that only happens for 31-Oct-2004 !! (was it the end of the world that day ???) Quote Link to comment https://forums.phpfreaks.com/topic/97116-date-function-error/#findComment-496960 Share on other sites More sharing options...
BlueSkyIS Posted March 20, 2008 Share Posted March 20, 2008 i don't get those results here. are you using Windows PHP or *nix? my output from your first post is this: 2004 10 30 23 2004 10 31 00 so, i'm not getting the same date/time. the same day, yes, but 1 hour off. 1099202400 - 1099198800 = 3600 seconds = 1 hour. there appears to be something wrong with your system Quote Link to comment https://forums.phpfreaks.com/topic/97116-date-function-error/#findComment-496962 Share on other sites More sharing options...
BlueSkyIS Posted March 20, 2008 Share Posted March 20, 2008 another example: print date("m/d/Y H:i:s",1099198800) ."<BR>"; print date("m/d/Y H:i:s",1099202400) ."<BR>"; output: 10/30/2004 23:00:00 10/31/2004 00:00:00 Quote Link to comment https://forums.phpfreaks.com/topic/97116-date-function-error/#findComment-496968 Share on other sites More sharing options...
wildteen88 Posted March 20, 2008 Share Posted March 20, 2008 Look at the affect of different timezones: <?php date_default_timezone_set('America/New_York'); echo '<h1>' . date_default_timezone_get() . "</h1>\n"; print date("Y m d H:i:s",1099198800) ."<br />\n"; print date("Y m d H:i:s",1099202400) ."<br />\n"; echo '<br /><br />'; date_default_timezone_set('Europe/London'); echo '<h1>' . date_default_timezone_get() . "</h1>\n"; print date("Y m d H:i:s",1099198800) ."<br />\n"; print date("Y m d H:i:s",1099202400) ."<br />\n"; echo '<br /><br />'; date_default_timezone_set('Australia/Sydney'); echo '<h1>' . date_default_timezone_get() . "</h1>\n"; print date("Y m d H:i:s",1099198800) ."<br />\n"; print date("Y m d H:i:s",1099202400) ."<br />\n"; ?> Output: America/New_York 2004 10 31 01:00:00 2004 10 31 01:00:00 Europe/London 2004 10 31 05:00:00 2004 10 31 06:00:00 Australia/Sydney 2004 10 31 16:00:00 2004 10 31 17:00:00 The result you are recieve is infact correct. However I'm not sure why for America timezone the dates are the same. Quote Link to comment https://forums.phpfreaks.com/topic/97116-date-function-error/#findComment-496971 Share on other sites More sharing options...
rhodesa Posted March 20, 2008 Share Posted March 20, 2008 The dates are the same due to Day Light Savings time. At 2am, time moved back to 1am. If you include the GMT offset in the output you will see: <?php print date('r',1099198800); print date('r',1099202400); ?> Sun, 31 Oct 2004 01:00:00 -0400 Sun, 31 Oct 2004 01:00:00 -0500 Quote Link to comment https://forums.phpfreaks.com/topic/97116-date-function-error/#findComment-496973 Share on other sites More sharing options...
ddd119 Posted March 20, 2008 Author Share Posted March 20, 2008 Guys, thanks so much for help ... I don't think it is a timezone problem. Maybe I did not make my point quite clear: here is the same code modified so it does not depends on the timezone: print date("Y m d H",mktime(01,0,0,10,31,2004)) ."\n"; print date("Y m d H",mktime(01,0,0,10,31,2004) +3600) ."\n"; and the output: 2004 10 31 01 2004 10 31 01 it is obvious so wrong.... To the previous question: it first happened on a Linux server (PHP 4.3.9) and I reproduce it on XP (PHP 5.3) Quote Link to comment https://forums.phpfreaks.com/topic/97116-date-function-error/#findComment-497029 Share on other sites More sharing options...
rhodesa Posted March 20, 2008 Share Posted March 20, 2008 Did you see my post? The dates are the same due to Day Light Savings time. At 2am, time moved back to 1am. If you include the GMT offset in the output you will see: <?php print date('r',1099198800); print date('r',1099202400); ?> Sun, 31 Oct 2004 01:00:00 -0400 Sun, 31 Oct 2004 01:00:00 -0500 It's also clear if you use the DST switch for date: print date("Y m d H I",mktime(01,0,0,10,31,2004)) ."\n"; print date("Y m d H I",mktime(01,0,0,10,31,2004) +3600) ."\n"; and the output: 2004 10 31 01 1 2004 10 31 01 0 Quote Link to comment https://forums.phpfreaks.com/topic/97116-date-function-error/#findComment-497035 Share on other sites More sharing options...
ddd119 Posted March 20, 2008 Author Share Posted March 20, 2008 I think you are right. Thanks for reply. Quote Link to comment https://forums.phpfreaks.com/topic/97116-date-function-error/#findComment-497042 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.