note 112703 deleted from function.strtotime by derick

From: Date: Sun, 03 Nov 2013 15:17:13 +0000
Subject: note 112703 deleted from function.strtotime by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197400@lists.php.net to get a copy of this message
Note Submitter: aw2010 at gmail dot com ---- 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.

« previous php.notes (#197400) next »