How to compare two dates without years in php?

前端 未结 3 612
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-20 06:18

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

3条回答
  •  爱一瞬间的悲伤
    2021-01-20 07:14

    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)) {
    
    }
    

提交回复
热议问题