user2228185 user2228185 - 7 months ago 11
PHP Question

PHP Check if date is past in the format 10-08-2015

I'm trying to check if the specific given date is past or not with PHP, I cannot change the date format as there are thousands of records like this in the database.

$actdate = '10-08-2015';

The format is day-month-year

Thank You

Edit: Get it working, thanks to Aruna Warnasooriya.

$actdate = "10-08-2015";
$yourdate = date_create(date($actdate));
$mydate = $yourdate->format("Y-m-d");
$date = new DateTime($mydate);
$now = new DateTime();

if($date < $now) {echo 'date is in the past';} else {echo 'date is not in the past'; }



$today = date("d-m-Y");

you can create a date using date_create function.This will create data object.

$actdate = "10-08-2015";
$yourdate = date_create(date($actdate));

format your date as you this;

echo $yourdate->format("d-m-Y");