Calculate number of days between two given dates

后端 未结 3 1490
忘了有多久
忘了有多久 2021-01-25 16:42

Can anyone correct the error in my script to calculate the number of days between 2 dates. The dates have been input through a form, the variable info is as followed:

3条回答
  •  感情败类
    2021-01-25 17:24

    Here's an easy way:

    $depart = strtotime(implode(' ', $_POST['departon']));
    $return = strtotime(implode(' ', $_POST['returnon']));
    
    $diff = floor(($return - $depart) / (60 * 60 * 24));
    

    Note: there's only 30 days in June.

提交回复
热议问题