I want to identify and calculate any difference between two time zones, when the hour is expressed in 0-23 format.
The problem is I don't know how to handle a situation where it is 1AM (1 in 0-23 format) in one place(the server location) and 11PM (23) in the other(the browser logging on). In other words I don't know how to calculate this difference when it crosses over midnight.
The difference in this example is 2 hours, because 11PM is 2 hours behind 1AM.
Using 24 hour format, this means 1 minus 11 would have to equal 2. Obviously it doesn't. It equals -10
Does anyone know how to do the calculation of this difference in 0-23 format, then convert the result to 1-12 format?
In this example, the script on the server would know its own time is 1 (1AM), when it receives the data that a browser logging onto it has a local time of 23 (11PM), it would calculate the difference in 0-23 format, see the difference is 2 hours, then send its own current time (1) to the browser, adjusted for the browsers local time, so the browser can display 11PM on its own screen - not from its own clock, but because the server tells it to.
1-2 = 11PM
Obviously 1-2 does not equal 11. Does anyone know how the math works here?
Thanks