Checking the difference between two dates

后端 未结 2 1271
执笔经年
执笔经年 2021-01-26 07:37

i\'m attempting to make an if statement to compare two time/dates and see if the second date is less than 24 hours after the first date entered. if it is it should not allow the

2条回答
  •  无人共我
    2021-01-26 08:25

    You can get the difference in seconds by converting the two DateTime objects to timestamps. $diffInSeconds = $future_date->getTimestamp() - $now->getTimestamp();

    Maybe it would be better to use strtotime, if the DateTime objects are only required for this operation.

提交回复
热议问题