note 53711 added to function.mktime
| From: | phpprinceatphpprincedotcom at osu1 dot php dot net | Date: | Fri, 10 Jun 2005 02:11:40 +0000 |
| Subject: | note 53711 added to function.mktime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-90202@lists.php.net to get a copy of this message | ||
i was writing a mini auction script and tried to replicate ebay's 7 day listing. so if you post
your auction today, it will end exactly 7 days later, exact up to the seconds.
$today = date("Y-m-d H:i:s"); // get today's date
$sep = explode(" ",$today); // split into day and time
$day = $sep[0];
$time = $sep[1];
$timesep = explode(":",$time); // split time into hr, min, sec
$hour = $timesep[0];
$min = $timesep[1];
$sec = $timesep[2];
$enddate = mktime($hour,$min,$sec, date("m"),date("d")+7,date("Y"));
// add 7 to the day, the hour, minutes and second are grabbed from the current time using variables
from the $timesep explode
$enddate = date("Y-m-d H:i:s", $enddate); // the enddate
echo $enddate;
voila!
----
Manual Page -- http://www.php.net/manual/en/function.mktime.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+53711
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53711&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53711&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53711&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53711&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53711&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+53711&report=yes
Search -- http://master.php.net/manage/user-notes.php