php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71369 strftime
Submitted: 2016-01-14 15:05 UTC Modified: 2016-01-15 01:22 UTC
From: info at jdv dot ch Assigned:
Status: Not a bug Package: Date/time related
PHP Version: Irrelevant OS: centOS 6
Private report: No CVE-ID: None
 [2016-01-14 15:05 UTC] info at jdv dot ch
Description:
------------
for($i=12;$i>=0;$i--){
  $dt 	= mktime(0, 0, 0, date("m")-$i, '1', date("Y"));
  $mois[] = 	date('M-y',$dt) .';'.
	 	utf8_encode(strftime("%h %g",$dt)) .';'.
	 	$dt;
	 	}
var_dump($mois);

Test script:
---------------
Today january 2016 the last 2 lines are:

array(3) { [0]=> string(6) "Dec-15" [1]=> string(8) "déc. 15" [2]=> string(10) "1448924400" }

array(3) { [0]=> string(6) "Jan-16" [1]=> string(8) "janv. 15" [2]=> string(10) "1451602800" }

See [1] of the last line... why janv. 15 and not janv. 16 ??

Expected result:
----------------
array(3) { [0]=> string(6) "Jan-16" [1]=> string(8) "janv. 16" [2]=> string(10) "1451602800" }

Actual result:
--------------
array(3) { [0]=> string(6) "Jan-16" [1]=> string(8) "janv. 15" [2]=> string(10) "1451602800" }

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-01-15 01:22 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2016-01-15 01:22 UTC] requinix@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

http://php.net/strftime
%g is the ISO-8601:1988 year number. Not the normal year number. Try %y instead.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 07:01:32 2024 UTC