|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-09-02 11:00 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 07:00:01 2025 UTC |
Description: ------------ I notified that code like echo date('r', strtotime('1 day ago')); always returns 00:00:00 time for last day, but if I use code echo date('r', mktime(date('h'), date('i'), date('s'), date('m'), date('d') - 1, date('Y'))); it returns date representation with a correct time, exactly one day ago. Why it always returns midnight time for last day? If I use '24 hours ago' or '84600 seconds ago' - I got the same wrong time of midnight. Reproduce code: --------------- echo date('r', mktime(date('h'), date('i'), date('s'), date('m'), date('d') - 1, date('Y'))), '<br />'; echo date('r', strtotime('1 day ago')), '<br />'; echo date('r', strtotime('24 hours ago')), '<br />'; echo date('r', strtotime('86400 seconds ago')), '<br />'; Expected result: ---------------- Wed, 1 Sep 2004 12:48:54 +0400 Wed, 1 Sep 2004 12:48:54 +0400 Wed, 1 Sep 2004 12:48:54 +0400 Wed, 1 Sep 2004 12:48:54 +0400 Actual result: -------------- Wed, 1 Sep 2004 12:48:54 +0400 Wed, 1 Sep 2004 00:00:00 +0400 Wed, 1 Sep 2004 00:00:00 +0400 Wed, 1 Sep 2004 00:00:00 +0400