|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-09-24 14:34 UTC] cmb@php.net
-Status: Open
+Status: Verified
[2020-09-24 14:34 UTC] cmb@php.net
[2022-05-13 15:53 UTC] derick@php.net
-Status: Verified
+Status: Wont fix
[2022-05-13 15:53 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 05:00:01 2025 UTC |
Description: ------------ Hi all, I wrote some php code that operates & logs data on a solar PV system. It makes use of date_sunrise / date_sunset methods to determine approximately when the system should be active. The system failed to start today because the next sunrise time was off by 24h. After evaluating the code and writing a short script, confirmed that the date_sunrise / date_sunset functions appear to skip a day at midnight Sept 23-24, 2020 - at least when given lat/long coordinates in New Zealand when the local machine is set to NZST (UTC+12). When given a time after Sept 24th, the returned sunrise/sunset times will be 1 day in the future. Attaching sample code to reproduce the issue. Thanks for any update. Test script: --------------- #!/usr/bin/php <?php $today=1600776000; // 2020-09-23 00:00:00 NZST (= 2020-09-22 12:00:00 UTC) $i=0; while ($i<=72) { print($today." ".date('Y-m-d H:i:s',$today)." Rise:". date_sunrise($today,SUNFUNCS_RET_TIMESTAMP,-38.6623,178.0176)." Set:". date_sunset($today,SUNFUNCS_RET_TIMESTAMP,-38.6623,178.0176). "\n"); ++$i; $today+=3600; } ?> Expected result: ---------------- Test code should generate a list of 72 entries by hour. Every 24 entries the Rise/Set values for sunrise/sunset should increment by roughly 86400 (1 day in seconds). I'm not actually clear on exactly when this method is expected to increment the date - it appears to depend on the current timezone setting (or perhaps solar midnight at the lat/long?). Regardless, at local (NZST) midnight on Sept 23/24 the returned values increment by 2 days. Here is a sample line from the output on Sept 23 when run in New Zealand Standard Time that works as expected: 1600819200 2020-09-23 12:00:00 Rise:1600797323 Set:1600841112 Actual result: -------------- Here is a portion of the result for 4 key points in time when run on a Raspberry Pi set to New Zealand Standard Time: 1600819200 2020-09-23 12:00:00 Rise:1600797323 Set:1600841112 1600858800 2020-09-23 23:00:00 Rise:1600797323 Set:1600841112 1600862400 2020-09-24 00:00:00 Rise:1600970027 Set:1601013966 1600905600 2020-09-24 12:00:00 Rise:1600970027 Set:1601013966 Lines 1 and 2 are correct / expected, lines 3 and 4 are incorrect - Rise and Set values should be about 86400 (1 day) lower.