php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29946 date('r', strtotime('day ago')) always returns 00:00:00 time for last day
Submitted: 2004-09-02 10:49 UTC Modified: 2004-09-02 11:00 UTC
From: zukker at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.0.1 OS: RH 9.1, WinXP
Private report: No CVE-ID: None
 [2004-09-02 10:49 UTC] zukker at gmail dot com
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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-02 11:00 UTC] derick@php.net
Duplicate of http://bugs.php.net/bug.php?id=28209.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Dec 02 07:00:01 2025 UTC