I would like to compare the two dates ,one date is which the 02 aug 1921 , and the second date is present date.How to compare the old date and present date day and month .if
Probably the most straight forward way is strtotime and date.
$date1 = '1 Aug 2012';
$date2 = '1 Aug 1912';
if (date('m-d', strtotime($date1)) === date('m-d', strtotime($date2)) {
}
Why don't you split the dates into year, month and day? and then:
if (($month1 == $month2) && ($day1 == $day2)) {
echo 'hi';
}
If you are on PHP 5.3 you can use the new DateTime class:
$oDate1 = new DateTime( $datetime1 );
$oDate2 = new DateTime( $datetime2 );
if( $oDate1->format('m-d') == $oDate2->format('m-d')
echo 'yes';