note 54942 added to function.time
| From: | jt at imen dot org dot uk | Date: | Wed, 20 Jul 2005 10:40:23 +0000 |
| Subject: | note 54942 added to function.time | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-92206@lists.php.net to get a copy of this message | ||
Too many people are doing this in here and its BAD programming practice:
BAD:
<?
$timeinfuture = time() + 60 * 60;
?>
GOOD:
<?
$timeinfuture = strtotime("+1 hour");
?>
Reasoning:
Leap days / seconds etc. If you are doing things like +1 day, and a leap year comes around, then you
start doing things an hour out for six months of the year. Please see the strtotime function. (Ok ok
I will accept people doing things like time + 10 etc for very small movements but anything that is
60*60*anything is not right)
----
Manual Page -- http://www.php.net/manual/en/function.time.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54942
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54942&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54942&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54942&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54942&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54942&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54942&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54942&report=yes
Search -- http://master.php.net/manage/user-notes.php