php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #68944 strftime %G problem with 31-12-2013
Submitted: 2015-01-29 13:40 UTC Modified: 2015-01-29 16:01 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:0 (0.0%)
From: kesavan dot krishnan at krds dot fr Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.4.37 OS: ubuntu 13.10
Private report: No CVE-ID: None
 [2015-01-29 13:40 UTC] kesavan dot krishnan at krds dot fr
Description:
------------
---
From manual page: http://www.php.net/faq
---
In php 5.4.35 i user strftime %A %e %B %G to get the date information.But if am passing date 31-12-2011, 31-12-2012, 31-12-2013, 31-12-2014 it return the year number+1.For exmp.if year is 2013 it return 2014.

Test script:
---------------
$mytime	=	new DateTime('2012-12-31');
echo strftime('%A %e %B %G', $mytime->getTimestamp());

Expected result:
----------------
Monday 31 December 2012

Actual result:
--------------
Monday 31 December 2013

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-01-29 14:04 UTC] gabri dot ns at gmail dot com
please use %Y

%G, %g, %V, and %u is used for ISO8601 weekdays. please see the documentation of %V for more information. http://php.net/manual/en/function.strftime.php
 [2015-01-29 16:01 UTC] danack@php.net
-Status: Open +Status: Not a bug
 [2015-01-29 16:02 UTC] danack@php.net
Yeah - you almost certainly don't want to use %G http://en.wikipedia.org/wiki/ISO_week_date

"The ISO 8601 definition for week 01 is the week with the year's first Thursday in it. Hence the earliest possible dates are 29 December through 4 January, the latest 4 through 10 January."
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 23:01:31 2024 UTC