ID: 22976
User updated by: scochrane at mackaysstores dot co dot uk
-Summary: gmdate()/gmmtime() and date()/mktime() not consistant
Reported By: scochrane at mackaysstores dot co dot uk
-Status: Bogus
+Status: Open
Bug Type: Date/time related
Operating System: NT4 Server
PHP Version: 4.3.0
New Comment:
By substituting mktime() with strtotime() has the same problem.
On the strtotime page of the manual - one of the examples given states
'echo strtotime ("last Monday"), "\n";' - so I beleave my sytax is
valid.
With my script ammended to be valid (as below) I think this is a bug.
function last_sunday() {
return gmdate("Y-m-d", strtotime("Last Sunday"));
}
echo "Last Sunday is returned as: ".last_sunday();
With Daylight saving on the above = 2003-03-29
With Daylight saving off the above = 2003-03-30
I have also use the GMT keyword with strtotime(), but this fails also.
Previous Comments:
------------------------------------------------------------------------
[2003-03-31 05:51:58] [EMAIL PROTECTED]
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.
Thank you for your interest in PHP.
Neither mktime() nor gmmktime() understands arguments like "last
Sunday" -- please go and re-read the documentation for those functions.
If you have any further questions, please ask them on the php-general
list.
------------------------------------------------------------------------
[2003-03-31 05:39:46] scochrane at mackaysstores dot co dot uk
I have 2 Servers - 1 has Automatic Daylight Saving on, the other has it
off. Both Servers have same PHP version and O/S (NT4 Server).
When I use this:
echo gmdate("Y-m-d", mktime("last Sunday")); // gmdate
it returns:
2003-03-30 on Server 1 and
2003-03-31 on Server 2
-------------------------------
when I use this:
echo date("Y-m-d", mktime("last Sunday")); // no gmdate!
it returns:
2003-03-31 on Server 1 and
2003-03-31 on Server 2
-------------------------------
When I use this:
echo gmdate("Y-m-d", gmmktime("last Sunday")); // gmdate and gmtime!
it returns:
2003-03-31 on Server 1 and
2003-03-30 on Server 2
-------------------------------
when I use this:
echo date("Y-m-d", gmmktime("last Sunday")); // gmmktime!
it returns:
2003-03-31 on Server 1 and
2003-03-30 on Server 2
So I have used every combination and cannot get both Servers to return
the correct date. I need it to return 2003-03-30 on both Servers - as
it should.
p.s. I cannot just change the 'Automatic Daylight' configuration as I
need it to run in over 250 seperate Servers (they may have different OS
settings)!
Cheers,
Stuart
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=22976&edit=1