I often need to display information based on or influenced by a user's actual local time which differs across time zones. Is there a reliable way of getting a user's current time and/or timezone?
- Server-side code is based on the website host or user's ISP
- Client-side code is based on the user's system clock which is too easily manipulated
- Is it necessary to pinpoint a user's geo-location?
- Can the ISP time be an accurate guide?
- Users OS clocks can vary or be modified by users?
Only 1 hour, 3 minutes, 56 seconds to go!
Issue: seconds to go based on what; The user's OS clock, the hosts server time (plus or minus offset), ISP system time. This is easy if the clock finishes at the same time for all timezones, but trickier if it's a countdown to something like midnight in the user's local time zone)
Item posted at 3:03pm (10 seconds ago)
Issue: 10 seconds is calculated regardless of user, the time is adjusted to match the user's time zone.
This restaurant is open now until midnight (AEST).
Issue: Giving a time such as midnight can be calculated by offsetting from the server-side but using psudo times such as now, in 2 hours is based on the user's time.
time() outputs the server time. This can be offset depending on the user's timezone.
Date() outputs the user's computer clock time which is too easily manipulated.