Yes, jmrker, but your script depends on (a) the users' computer clocks being set correctly and (b) the users being in the same time zone as the server [though it's easy to adjust for the latter].
See how I pass the server time in, from PHP, and then use the discovered offset in all other calculations.
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.