Jump to content

How do I add 3 days to a date


kpetsche20

Recommended Posts

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

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);
  }
}

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'];

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.