Jump to content

[SOLVED] Adding Time?


monkeypaw201

Recommended Posts

I have a database with a time column where i insert the time using the date("now") function....

 

I need to be able to add 24 hours... Using that new variable i need to find out if that date/time has already passed or not. So..

 

1. How do I add 24 hours?

 

2. Will $added_time < $date("now) work for an if..else?

Link to comment
https://forums.phpfreaks.com/topic/117271-solved-adding-time/
Share on other sites

Dunno how you plan on retrieving this date in question, but assuming you have an id associated to it in the row...

// important thing here is to get the date, so do whatever you got to do to get it
$sql = "select datecolumn from table where id = '$id'";
$result = mysql_query($sql);

if ($result) {
  $date = mysql_result($result, 0, 0);
  
  $date = strtotime($date) + 86400;
  
  if ($date > time()) {
     // do something
  }
}

 

Link to comment
https://forums.phpfreaks.com/topic/117271-solved-adding-time/#findComment-603247
Share on other sites

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.