note 112703 added to function.strtotime
| From: | aw2010 at gmail dot com | Date: | Mon, 15 Jul 2013 09:55:37 +0000 |
| Subject: | note 112703 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-195615@lists.php.net to get a copy of this message | ||
A handy way to create an array index based on a time stamp that is aligned with the day of the time
stamp:
<?php
$daily_news = array();
$daily_news[strtotime(date("Y-m-d", time()))] = "Today's newz.";
?>
Later on in the day, the user corrected a typo:
<?php
$daily_news[strtotime(date("Y-m-d", time()))] = "Today's news. Updated.";
?>
So the first entry is updated rather than creating a new entry. And the index value may be used to
extract the correct date.
I found that trying to round down the time stamp number by dividing by the number of seconds in a
day lost synchronization with the correct date.
----
Server IP: 49.212.134.217
Probable Submitter: 114.176.167.100
----
Manual Page -- http://php.net/manual/en/function.strtotime.php
Edit -- https://master.php.net/note/edit/112703
Del: integrated -- https://master.php.net/note/delete/112703/integrated
Del: useless -- https://master.php.net/note/delete/112703/useless
Del: bad code -- https://master.php.net/note/delete/112703/bad+code
Del: spam -- https://master.php.net/note/delete/112703/spam
Del: non-english -- https://master.php.net/note/delete/112703/non-english
Del: in docs -- https://master.php.net/note/delete/112703/in+docs
Del: other reasons-- https://master.php.net/note/delete/112703
Reject -- https://master.php.net/note/reject/112703
Search -- https://master.php.net/manage/user-notes.php