php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35039 strftime weird math
Submitted: 2005-10-31 19:41 UTC Modified: 2005-10-31 19:51 UTC
From: arcivanov at mail dot ru Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.0.5 OS: Slackware 10.1 (kern v2.6.14)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: arcivanov at mail dot ru
New email:
PHP Version: OS:

 

 [2005-10-31 19:41 UTC] arcivanov at mail dot ru
Description:
------------
strftime always displays Jan of year X as Jan of year X-1 when using '%B, %G' format for some years

Reproduce code:
---------------
function print_time($curr_time)
{
    echo ("Time according to date:\t\t" . date("Y-m-d H:i:s", $curr_time) . "\n");
    echo ("Time according to strftime:\t" . strftime('%B, %G', $curr_time) . "\n");
}

$curr_time = strtotime("2006-01-01 00:00:01");print_time ($curr_time);
$curr_time = strtotime("2005-01-01 00:00:01");print_time ($curr_time);
$curr_time = strtotime("2004-01-01 00:00:01");print_time ($curr_time);
$curr_time = strtotime("2003-01-01 00:00:01");print_time ($curr_time);
$curr_time = strtotime("2002-01-01 00:00:01");print_time ($curr_time);
$curr_time = strtotime("2001-01-01 00:00:01");print_time ($curr_time);
$curr_time = strtotime("2000-01-01 00:00:01");print_time ($curr_time);
$curr_time = strtotime("1999-01-01 00:00:01");print_time ($curr_time);


Expected result:
----------------
Time according to date:         2006-01-01 00:00:01
Time according to strftime:     January, 2006
Time according to date:         2005-01-01 00:00:01
Time according to strftime:     January, 2005
Time according to date:         2004-01-01 00:00:01
Time according to strftime:     January, 2004
Time according to date:         2003-01-01 00:00:01
Time according to strftime:     January, 2003
Time according to date:         2002-01-01 00:00:01
Time according to strftime:     January, 2002
Time according to date:         2001-01-01 00:00:01
Time according to strftime:     January, 2001
Time according to date:         2000-01-01 00:00:01
Time according to strftime:     January, 2000
Time according to date:         1999-01-01 00:00:01
Time according to strftime:     January, 1999


Actual result:
--------------
Time according to date:         2006-01-01 00:00:01
Time according to strftime:     January, 2005
Time according to date:         2005-01-01 00:00:01
Time according to strftime:     January, 2004
Time according to date:         2004-01-01 00:00:01
Time according to strftime:     January, 2004
Time according to date:         2003-01-01 00:00:01
Time according to strftime:     January, 2003
Time according to date:         2002-01-01 00:00:01
Time according to strftime:     January, 2002
Time according to date:         2001-01-01 00:00:01
Time according to strftime:     January, 2001
Time according to date:         2000-01-01 00:00:01
Time according to strftime:     January, 1999
Time according to date:         1999-01-01 00:00:01
Time according to strftime:     January, 1998


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-31 19:51 UTC] derick@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

Please read the documentation, %G is the ISO year, and if you use it together with the ISO week modifier (%V) then you'll see that jan 01 falls in the last week of the previous year.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Dec 03 10:00:01 2025 UTC