Posted: Mon Oct 29, 2007 8:38 pm Timezone Converter
I can't seem to find a way to convert timezone without having it set off of my computer clock. I want a timezone converter that converts from a date/time that I enter to a date/time zone that's specificed.
I basically want it to subtract 1.5 hours from whichever date/time I enter. Does anyone know any coding for this? I can't seem to find it anywhere. I can find lots of timezone converters that convert the date/time from the computer, but that's not what I'm looking for. Thanks
Posted: Tue Dec 04, 2007 7:58 pm Javascript's "Date" object
JS seems to support only UTC and local time. You could use Date.parse to create the date from a string, or roll your own date parser using the Date.set* methods (see W3 School or DevGuru's "Date" object reference for more info on the "set" methods, amoung others). Once you have a date object, you can use (e.g.) Date.getHours and Date.setHours, or getTime and Date.setTime (or Date constructor), to manually convert based on timezone. You'll have to write code to figure out the proper offset; Date.getTimezoneOffset may be of use.
Note that setHours handles cases where adding/subtracting hours takes the time past midnight just fine (e.g. yesterday.setHours(today.getHours - 24) will set 'yesterday' to 1 day earlier than 'today').
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum