php-src icon indicating copy to clipboard operation
php-src copied to clipboard

strftime give wrong year

Open Djibs opened this issue 4 years ago • 1 comments

Description

If you run strftime() on a date in this new year, it still shows 2021 . If I put the date of today (2022-01-04), the bug disappears

The following code:

<?php 

$date1 = '2022-01-01';
$date2 = '2022-01-04'; //today

echo $date1 = strftime("%d %B %G", strtotime($date1));
echo $date2 = strftime("%d %B %G", strtotime($date2));

Resulted in this output:

01 January 2021
04 January 2022

But I expected this output instead:

01 January 2022
04 January 2022

PHP Version

PHP 7.4

Operating System

No response

Djibs avatar Jan 04 '22 10:01 Djibs

See https://github.com/php/php-src/issues/7864#issuecomment-1003549994

iluuu1994 avatar Jan 04 '22 10:01 iluuu1994