PHP - Comparing time

后端 未结 2 884
迷失自我
迷失自我 2021-01-07 02:56

I\'m working on a calendar/planner web app and I need to compare the start and end times of events before I store them in my DB. An event can only have a range of one day an

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-07 03:20

    If you're running PHP 5.3, you can use the diff() method of DateTime objects to get the difference in between two dates. But it's possible to do with just timestamps too (1 day = 86400 seconds)

提交回复
热议问题