Doc #67870 [Com]: jdtounix() claims localtime, but that's not true

From: Date: Thu, 23 Oct 2014 07:26:32 +0000
Subject: Doc #67870 [Com]: jdtounix() claims localtime, but that's not true
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-11570@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 Comment by: saeed at hubaishan dot com Reported by: asphp at dsgml dot com Summary: jdtounix() claims localtime, but that's not true Status: Open Type: Documentation Problem Package: Documentation problem PHP Version: Irrelevant Block user comment: N Private report: N New Comment: you can test this by: <?php echo (jdtounix(rand(2440588,2465342))%86400) //always 0 ?> Previous Comments: ------------------------------------------------------------------------ [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 (#11570) next »