Wanye
Wanye

Reputation: 485

PHP How to find if 2 dates are equal

I have a date field that submits the chosen dates and I want to find out if the end date is today.

So for example I want to compare 21-May-2012(today) to 21-May-2012(submitted) and see if they match or not.

Can someone please help?

Thanks in advance

Upvotes: 4

Views: 20636

Answers (2)

Dheeraj Dheerr
Dheeraj Dheerr

Reputation: 1

$currentDate  = '21-May-2012';
$submitDate = '21-May-2012';

if ($submitDate == $currentDate)
  echo 'Same';
else
  echo 'Different';

Upvotes: 0

dynamic
dynamic

Reputation: 48091

if ( strtotime($current) != strtotime($sumbit) )

Or just simplier:

$currentDate  = '21-May-2012';
$submit = '21-May-2012';

if ($submit != $currentDate)
  echo 'Different';

Upvotes: 16

Related Questions