
Originally Posted by
tekboy
how do i auto adjust time base on user local time
The Date object already has the ability to adjust dates from UTC to local time, though it depends on the correct configuration of the user's computer.
i want to put in a time like 1:00pm us time manually, how can i make this number automaticly change to whaterver time equivalent in user local timezone
Adjust the target time to the equivalent UTC. For example, 1300 EST (USA: -5 hours) is 1800 UTC. If the target is a fixed date, use the Date.UTC method to obtain a timestamp, and then construct the Date object:
Code:
var date = new Date(Date.UTC(2006, 10, 1, 18)); // 2006-11-01 18:00:00
Note that months start at zero, so 10 is November, not October.
If the target is based on the current date, use the setUTCHours method to change the hours, minutes, seconds, and milliseconds:
Code:
var date = new Date(); // Current time and date
date.setUTCHours(18); // Additional arguments set minutes, seconds, and ms

Originally Posted by
tech_support
I don't think you can unless you use some sort of sophisticated IP-tracking to pin-point the country, find out the time zone and add it accordingly.
IP addresses do not correspond to countries, nor does country necessarily determine the necessary local time adjustments (especially in the USA, for example).
Mike
Bookmarks