|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #40171 There should be a way to create DateTime object from UTC timestamp.
Submitted: 2007-01-19 16:27 UTC Modified: 2007-01-19 18:25 UTC
Avg. Score:3.4 ± 1.2
Reproduced:27 of 29 (93.1%)
Same Version:14 (51.9%)
Same OS:8 (29.6%)
From: rkumar at msgme dot com Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 5.2.0 OS: Linux
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-01-19 16:27 UTC] rkumar at msgme dot com
The constructor for DateTime object currently takes a string 
as a parameter. In most of the scenarios that I have encountered I need to create a DateTime object from UTC timestamp. Can the constructor  be changed to accept string or integer? 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-01-19 18:25 UTC]
That would be too confusing, as PHP auto casts and "20070119" is something quite different from the unix timestamp 20070119. What you can do is pass this to the ctor: "@20070119" - the @ makes it interpret as a Unix timestamp.
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Wed Nov 25 08:01:54 2015 UTC