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


i'm trying check if specific given date past or not php, cannot change date format there thousands of records in database.

$actdate = '10-08-2015'; 

the format day-month-year

thank you

edit: working, 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 in past';} else {echo 'date not in past'; } 

php :

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

you can create date using date_create function.this create data object.

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

format date wish.like this;

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

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -