note 52684 added to function.strtotime

From: Date: Mon, 09 May 2005 20:49:30 +0000
Subject: note 52684 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-89177@lists.php.net to get a copy of this message
Here's a quick one-line function you can use to get the time difference for relative times. But default, if you put in a relative time (like "1 minute"), you get that relative to the current time. Using this function will give you just the time difference in seconds: <?php function relative_time( $input ) { return strtotime($input) - time(); } ?> For example "1 minute" will return 60, while "30 seconds ago" will return -30 Valid relative time formats can be found at http://www.gnu.org/software/tar/manual/html_chapter/tar_7.html#SEC115 ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52684 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52684&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52684&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52684&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52684&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52684&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52684&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#89177) next »