3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set( 'UTC' ); define( "TIMESTAMP_FORMAT", "Y-m-d G:i:s" ); $aString = "2017-03-01 23:11:16"; echo "String to convert: ". $aString ."\r\n"; $currentTime = date( TIMESTAMP_FORMAT ); echo "Current Time: ". $currentTime."\r\n"; $dateToCheck = new DateTime($aString); echo "Date To Check: ". $dateToCheck->format(TIMESTAMP_FORMAT)."\r\n"; if($dateToCheck < $currentTime) { echo 'Date is in the past'; } else { echo 'Date is in the future'; }

preferences:
106.88 ms | 1797 KiB | 5 Q