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
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: francois dot guerlez at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 16 23:01:33 2025 UTC