php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70314 Function date();
Submitted: 2015-08-20 18:21 UTC Modified: 2015-08-20 20:05 UTC
From: francois dot guerlez at gmail dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.6.12 OS: Debian Jessie
Private report: No CVE-ID: None
 [2015-08-20 18:21 UTC] francois dot guerlez at gmail dot com
Description:
------------
The function date() doesn't return the expected value.

Test script:
---------------
<?php

$date = '2014-12-29';
$time = strtotime($date);

$date = date('Y-m-d', $time);
echo "$date\n"; // Display : 2014-12-29

$date = date('Y-W', $time);
echo "$date\n"; // Display : 2014-01



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-20 20:05 UTC] rasmus@php.net
-Status: Open +Status: Not a bug
 [2015-08-20 20:05 UTC] rasmus@php.net
This looks correct to me. ISO week 01 for 2015 can start in 2014. Read
https://en.wikipedia.org/wiki/ISO_week_date
carefully. Especially:

    If 31 December is on a Monday, Tuesday or Wednesday, it is in week 01 of the next year.

In 2014 Dec.31 was on a Wednesday so Monday 12-29 is in week 01 which PHP is correctly telling you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 03:01:29 2024 UTC