|  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:42 of 50 (84.0%)
Same Version:21 (50.0%)
Same OS:15 (35.7%)
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: None
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-2020 The PHP Group
All rights reserved.
Last updated: Sat Feb 22 20:01:28 2020 UTC