php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53964 minutes on date function incorrect; see examples
Submitted: 2011-02-08 20:40 UTC Modified: 2011-02-08 20:45 UTC
From: greg at pswdb dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.3.5 OS: fedora 13
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: greg at pswdb dot com
New email:
PHP Version: OS:

 

 [2011-02-08 20:40 UTC] greg at pswdb dot com
Description:
------------
---
From manual page: http://www.php.net/function.date
---
  $d="2010-01-31 09:06:09"; 
  $i= strtotime($d);    
  echo  '<br>' . $d  ; 
  echo  '<br>' . date("Y-m-d h:m:s",$i); 
produces this:
2010-01-31 09:06:09
2010-01-31 09:01:09


  $d="2011-01-20 09:48:00"; 
  $i= strtotime($d);    
  echo  '<br>' . $d  ; 
  echo  '<br>' . date("Y-m-d h:m:s",$i); 
produces this:
2011-01-20 09:48:00
2011-01-20 09:01:00


  $d="2010-06-26 01:29:39"; 
  $i= strtotime($d);    
  echo  '<br>' . $d  ; 
  echo  '<br>' . date("Y-m-d h:m:s",$i); 
produces this:
2010-06-26 01:29:39
2010-06-26 01:06:39 




Expected result:
----------------
2010-01-31 09:06:09
2010-01-31 09:06:09

2011-01-20 09:48:00
2011-01-20 09:48:00

2010-06-26 01:29:39
2010-06-26 01:29:39







Actual result:
--------------


2010-01-31 09:06:09
2010-01-31 09:01:09

2011-01-20 09:48:00
2011-01-20 09:01:00

2010-06-26 01:29:39
2010-06-26 01:06:39




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-08 20:45 UTC] johannes@php.net
-Status: Open +Status: Bogus
 [2011-02-08 20:45 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Your format string includes "m" as in month twice. You need an "i" for minutes.

date("Y-m-d h:i:s",$i);
 [2011-02-08 21:03 UTC] greg at pwsdb dot com
echo  '<br>' . date("h:m:s a");
produces 
02:02:26 pm 
and (4 sec. later) 
my interactive fedora 14 command $ date 
produced 
Tue Feb  8 14:58:30 EST 2011
which is correct: It is 58 minutes after the hour, not 2 right now. 
... therefor, it is the date function in PHP, not linux, and it is not
the strtotime function. this time, it was not involved.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 16 09:01:28 2024 UTC