note 67973 deleted from function.date by bobby

From: Date: Thu, 07 Sep 2006 17:53:25 +0000
Subject: note 67973 deleted from function.date by bobby
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-116852@lists.php.net to get a copy of this message
Note Submitter: piranha-php_manual at thoughtcrime dot us ---- hsinche, Your code is incorrect. You add 86400 * 7 in at least one place to find the point in time exactly one week in the future. In the following circumstances, the difference between one Friday and the same time of day on the following Friday is not 86400 * 7 seconds: * A daylight savings switch has occurred. One additional hour (3600 seconds) has been added or lost, offsetting the time of your following Friday by that amount. * A leap year correction has been executed--e.g. on December 31st 2005, there were 86401 seconds. The clock continued onto 23:59:60 before reaching 00:00:00. This may not mean much in your code, but it spells all kinds of trouble if you ever want to compare the result of a similar calculation with a known value, or your time-of-day falls either on or just before midnight, or any other time when the accuracy of the time-of-day matters in your application. Although the discrete timescale (n seconds) is linear and infinite and intuitive; it does not map to the calendar and time-of-day systems, which have a laundry list of special rules, added up over time, all to varying ends. This is why you want to use your system's calendar functions for almost all time manipulation, unless you understand the consequences and they simply don't apply, or unless you're willing to implement the chaotic and arbitrary semantic nuances of the calendar and time-of-day system yourself.

« previous php.notes (#116852) next »