php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28562 Strtotime() or Date() Imroper Handling of time
Submitted: 2004-05-28 19:51 UTC Modified: 2004-05-31 12:14 UTC
From: aksuska at esoteritech dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.3.4 OS: Linux 2.4.25 (RH)
Private report: No CVE-ID: None
 [2004-05-28 19:51 UTC] aksuska at esoteritech dot com
Description:
------------
Time values are (IMHO) calculated incorrectly from 
strtotime(), or as passed through date(). See example 
below.

Config:
---------------------------
'./configure' '--prefix=/usr/local/' '--with-apxs=/etc/
httpd/bin/apxs' '--disable-cgi' '--enable-versioning' '--
enable-pic' '--disable-posix-threads' '--enable-memory-
limit' '--with-pear=/usr/local/lib/php' '--with-openssl=/
usr/local/ssl' '--disable-debug' '--enable-magic-quotes' '-
-disable-rpath' '--with-bz2=/usr' '--with-zlib' '--enable-
bcmath' '--enable-calendar' '--enable-ftp' '--enable-exif' 
'--with-curl=/usr' '--enable-dba' '--with-gdbm=/usr' '--
with-flatfile' '--with-inifile' '--enable-dbase' '--with-
gd' '--enable-gd-native-ttf' '--with-jpeg-dir=/usr' '--
with-png-dir=/usr' '--with-freetype-dir=/usr' '--with-
gettext=/usr' '--with-gmp' '--with-imap=/usr/local' '--
with-imap-ssl=/usr/local/ssl' '--enable-mbstring' '--
enable-mbstr-enc-trans' '--enable-mbregex' '--with-mcrypt=/
usr' '--with-mhash=/usr' '--with-unixODBC=/usr/local/
unixODBC' '--with-mysql=/usr/local/mysql' '--enable-
sockets' '--with-regex=system' '--enable-wddx' '--with-
expat-dir=/usr' '--enable-xslt' '--with-xslt-sablot=/usr' 
'--enable-inline-optimization' '--with-pspell=/usr/local'
----------------

php.ini diff:
-------------------
I can't provide this as the server isn't mine. I canb, 
however, provide a phpinfo() output on request.
--------------------

Reproduce code:
---------------
<?
$date = '3/31/04';
print date( 'Y-m-d H:m:s', strtotime( $date ) ) . "<BR>";

$date = date( 'm/d/y', time() );
print date( 'Y-m-d H:m:s', strtotime( $date ) ) . " ($date)<BR>";

$date = '03/31/04 00:00:00';
print date( 'Y-m-d H:m:s', strtotime( $date ) ) . "<BR>";

$date = '03/31/04 03:25:19';
print date( 'Y-m-d H:m:s', strtotime( $date ) ) . "<BR>";
?>

Expected result:
----------------
2004-03-31 00:00:00
2004-05-28 00:00:00 (05/28/04)
2004-03-31 00:00:00
2004-03-31 03:25:19


Actual result:
--------------
2004-03-31 00:03:00
2004-05-28 00:05:00 (05/28/04)
2004-03-31 00:03:00
2004-03-31 03:03:19


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-05-30 19:49 UTC] iliaa@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

When you don't specify the time, the timezone information 
is used, hence the extra 5 hours. 
 [2004-05-30 21:22 UTC] aksuska at esoteritech dot com
It might help if you look at my examples more closely. 
There is no 5 hour discrepancy anywhere.There is a 3 
minute, 5 minute, and 22 minute discrepancy. I can't see 
how this can be due to a time zone variance.
 [2004-05-31 12:14 UTC] derick@php.net
You use "m" for both Month and Minute, while you need to use "i" for Minute.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Dec 07 00:00:01 2025 UTC