php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #53712 DateTime::createFromFormat using format ('W') doesn't work
Submitted: 2011-01-11 11:35 UTC Modified: 2017-01-12 19:37 UTC
Votes:4
Avg. Score:4.5 ± 0.9
Reproduced:4 of 4 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: mpchanzy at proxecom dot fr Assigned:
Status: Wont fix Package: Date/time related
PHP Version: 5.3.5 OS: XP Pro
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
28 + 23 = ?
Subscribe to this entry?

 
 [2011-01-11 11:35 UTC] mpchanzy at proxecom dot fr
Description:
------------
---
From manual page: http://www.php.net/datetime.createfromformat#Liste de paramètres
---

DateTime::createFromFormat('W','1')
returns false when it should probably return the date of the first week of the year.

'W' is a date() compatible format

Test script:
---------------
$date = DateTime::createFromFormat('W','1');


Expected result:
----------------
it should return something like this:

public 'date' => string '2011-01-03 10:17:40' (length=19)
  public 'timezone_type' => int 3
  public 'timezone' => string 'UTC' (length=3)


Actual result:
--------------
false

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-11 11:45 UTC] mpchanzy at proxecom dot fr
-Summary: Weeks format ('W') doesn't work +Summary: DateTime::createFromFormat using format ('W') doesn't work
 [2011-01-11 11:45 UTC] mpchanzy at proxecom dot fr
I just changed the title to make it more explicit
 [2011-01-11 15:51 UTC] derick@php.net
-Package: Unknown/Other Function +Package: Translation problem
 [2011-01-11 15:51 UTC] derick@php.net
"W" is not part of that list at all—it is not supported. The documentation also states http://uk.php.net/manual/en/datetime.createfromformat.php:

The format that the passed in string should be in. See the formatting options below. In *most cases*, the same letters as for the date() can be used.

Perhaps you're looking at an outdated translation of the manual? It looks that the French version of the manual is indeed outdated.
 [2011-01-12 04:19 UTC] aharvey@php.net
-Type: Bug +Type: Documentation Problem
 [2011-01-12 18:57 UTC] altrozero at gmail dot com
This is probably more of a feature request than a bug as 'W' isn't listed in the 
documentation for DateTime::createFromFormat neither are a few other characters 
that are supported by date.

You may as well just use the date() function if you wish to use 'W'
 [2011-01-26 21:46 UTC] philip@php.net
-Type: Documentation Problem +Type: Feature/Change Request -Package: Translation problem +Package: Date/time related
 [2011-01-26 21:46 UTC] philip@php.net
Marking as a datetime feature request.
 [2015-06-24 10:36 UTC] simon dot lindhen at hotmail dot com
To create a DateTime from a week you can use: http://php.net/manual/en/datetime.setisodate.php
 [2017-01-12 19:37 UTC] heiglandreas@php.net
-Status: Open +Status: Wont fix
 [2017-01-12 19:37 UTC] heiglandreas@php.net
Thank you for your suggestion. As the previous comment suggests there is a way to solve this issue, so I'm closing this.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 15:01:30 2024 UTC