Jump to content

Convert Sting in to date


mflevie44

Recommended Posts

Edit* - Thought it was wrong function, actually malformed time string.

 

 

<?PHP

  $string = '2013-09-27 14:00:01';
 
  $timestamp = strtotime($string);
 
  if($timestamp < ($_SERVER['REQUEST_TIME'] - (60*60*24))) {
    echo 'True';
  }
 
?>

take a look at the DateTime class, particularly http://www.php.net/manual/en/datetime.createfromformat.php and http://www.php.net/manual/en/datetime.gettimestamp.php and http://www.php.net/manual/en/datetime.diff.php

 

 

TIP: if you are going to post two different questions don't give the same title - one could get removed as a duplicate post

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.