|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #67870 jdtounix() claims localtime, but that's not true
Submitted: 2014-08-20 09:14 UTC Modified: 2017-09-04 12:03 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: asphp at dsgml dot com Assigned: cmb (profile)
Status: Closed Package: Calendar related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2014-08-20 09:14 UTC] asphp at dsgml dot com
From manual page:

It says: "The time returned is localtime (and not GMT)."

But this is not true.

Part of the problem is bug #13187 which claims:

"so jdtounix returns localtime while
mysql unix_timestamp returns GMT"

Which is not true! It's actually exactly the opposite! MySQL returns localtime, and PHP returns GMT.

You can even look at the source code:

(uday * 24 * 3600)

No adjustment whatsoever for timezone.

Test script:
echo jdtounix(2440588) , "\n" . jdtounix(2440589);

Expected result:
If it was local time then I would not get:


But I do. Those times are exactly midnight UTC.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-08-20 09:16 UTC] asphp at dsgml dot com
And just to really confuse everyone, unixtojd() IS localtime, but doesn't say so in the documentation!

Source code:

if (!(ta = php_localtime_r(&ts, &tmbuf))) {
 [2014-10-23 07:26 UTC] saeed at hubaishan dot com
you can test this by:
echo (jdtounix(rand(2440588,2465342))%86400) //always 0
 [2017-01-28 17:12 UTC]
-Package: Documentation problem +Package: Calendar related
 [2017-09-04 11:41 UTC]
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2017-09-04 11:41 UTC]
> MySQL returns localtime, and PHP returns GMT.

Well, actually PHP returns UTC, but indeed not local time. Thanks!
 [2017-09-04 12:03 UTC]
Automatic comment from SVN on behalf of cmb
Log: Fix bug #67870 (jdtounix() claims localtime, but that's not true)
 [2017-09-04 12:03 UTC]
-Status: Verified +Status: Closed
 [2020-02-07 06:06 UTC]
Automatic comment on behalf of cmb
Log: Fix bug #67870 (jdtounix() claims localtime, but that's not true)
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jun 18 06:01:31 2024 UTC