Doc #67870 [Opn->Ver]: jdtounix() claims localtime, but that's not true

From: Date: Mon, 04 Sep 2017 11:41:18 +0000
Subject: Doc #67870 [Opn->Ver]: jdtounix() claims localtime, but that's not true
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-14950@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67870&edit=1 ID: 67870 Updated by: cmb@php.net Reported by: asphp at dsgml dot com Summary: jdtounix() claims localtime, but that's not true -Status: Open +Status: Verified Type: Documentation Problem Package: Calendar related PHP Version: Irrelevant -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: > MySQL returns localtime, and PHP returns GMT. Well, actually PHP returns UTC, but indeed not local time. Thanks! Previous Comments: ------------------------------------------------------------------------ [2014-10-23 07:26:32] saeed at hubaishan dot com you can test this by: <?php echo (jdtounix(rand(2440588,2465342))%86400) //always 0 ?> ------------------------------------------------------------------------ [2014-08-20 09:16:38] 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-08-20 09:14:56] asphp at dsgml dot com Description: ------------ --- From manual page: http://www.php.net/function.jdtounix --- 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: --------------- <? date_default_timezone_set('America/New_York'); echo jdtounix(2440588) , "\n" . jdtounix(2440589); Expected result: ---------------- If it was local time then I would not get: 0 86400 But I do. Those times are exactly midnight UTC. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67870&edit=1

« previous php.doc.bugs (#14950) next »