mflevie44 Posted September 28, 2013 Share Posted September 28, 2013 How can check This String '2013-09-12:14:00:01' is later than 24 hours of current time? Quote Link to comment https://forums.phpfreaks.com/topic/282509-convert-sting-in-to-date/ Share on other sites More sharing options...
Solution PaulRyan Posted September 28, 2013 Solution Share Posted September 28, 2013 (edited) 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'; } ?> Edited September 28, 2013 by PaulRyan Quote Link to comment https://forums.phpfreaks.com/topic/282509-convert-sting-in-to-date/#findComment-1451597 Share on other sites More sharing options...
Barand Posted September 28, 2013 Share Posted September 28, 2013 (edited) 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 Edited September 28, 2013 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/282509-convert-sting-in-to-date/#findComment-1451600 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.