-3

my date format is: Jan-21-2016 I want to check if it is in the past or not in PHP. How can I do it?

Marcus Adams
  • 53,009
  • 9
  • 91
  • 143
nilesh_ramteke
  • 135
  • 3
  • 8

1 Answers1

8

Using strtotime():

if(strtotime($date)<strtotime("today")){
    echo "past";
} elseif(strtotime($date)==strtotime("today")){
    echo "today";
} else {
    echo "future";
}
Ben
  • 8,894
  • 7
  • 44
  • 80