Get time difference

后端 未结 2 1076
[愿得一人]
[愿得一人] 2020-12-11 12:19

How can I compute time difference in PHP?

example: 2:00 and 3:30.

I want to convert the time to seconds then subtract them then convert it back to hours an

2条回答
  •  天命终不由人
    2020-12-11 12:44

    Check this link ...

    http://www.onlineconversion.com/days_between_advanced.htm

    I used this to calculate the difference between server time and the users local time. Grab the hour difference and drop that in a form when the user is registering. I then use it to update the time on the site for the user when they do stuff online.

    Once I got it working, I switched this line ...

    if (form.date1.value == "")
        form.date1.value = s;
    

    to ...

        form.date1.value = "";
    

    Now I can compare the user time and the server time! You can grab the seconds and mins as well.

提交回复
热议问题