kpetsche20 Posted December 29, 2008 Share Posted December 29, 2008 I need to add 3 days to a date, the date is in the format YYYY-MM-DD public function start_date_plus_3($league) { $sql = mysql_query("SELECT * FROM pleagues WHERE id = '".$league."'") or die(mysql_error()); while($data = mysql_fetch_array($sql)) { $starttime = $data['startdate'] $timestamp = strtotime($data['startdate']); } } Link to comment https://forums.phpfreaks.com/topic/138768-how-do-i-add-3-days-to-a-date/ Share on other sites More sharing options...
bluesoul Posted December 29, 2008 Share Posted December 29, 2008 I need to add 3 days to a date, the date is in the format YYYY-MM-DD public function start_date_plus_3($league) { $sql = mysql_query("SELECT * FROM pleagues WHERE id = '".$league."'") or die(mysql_error()); while($data = mysql_fetch_array($sql)) { $starttime = $data['startdate'] $timestamp = strtotime($data['startdate']); $newtime = strtotime("+3 days",$starttime); } } Link to comment https://forums.phpfreaks.com/topic/138768-how-do-i-add-3-days-to-a-date/#findComment-725572 Share on other sites More sharing options...
Mark Baker Posted December 29, 2008 Share Posted December 29, 2008 $newdate = strtotime('+3 days',strtotime('2008-12-29')); Link to comment https://forums.phpfreaks.com/topic/138768-how-do-i-add-3-days-to-a-date/#findComment-725578 Share on other sites More sharing options...
GingerRobot Posted December 29, 2008 Share Posted December 29, 2008 Better to do it all in the query: $sql = mysql_query("SELECT *,UNIX_TIMESTAMP(startdate + INTERVAL 3 DAY) AS timestamp FROM pleagues WHERE id = '".$league."'") or die(mysql_error()); The timestamp would then be in $data['timestamp']; Link to comment https://forums.phpfreaks.com/topic/138768-how-do-i-add-3-days-to-a-date/#findComment-725581 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.