mde / timezone-js

DEPRECATED: Timezone-enabled JavaScript Date object. Uses Olson zoneinfo files for timezone data.
824 stars 183 forks source link

Instantiating now or passing another date #56

Closed pixelfreak closed 11 years ago

pixelfreak commented 11 years ago

Is there a way to instantiate a timezone-js date of now? (ie: like new Date())

Also, is there a way to convert an existing date object into a timezone-js date?

Thanks!

pixelfreak commented 11 years ago

K, I looked at the source code. Looks like instantiating now is possible by simply passing just the tz like so:

var dt = new timezoneJS.Date('America/Los_Angeles');

But there is no way to convert an existing date object into a timezone-js date, aside from passing the individual date components.

longlho commented 11 years ago

var dt = new timezoneJS.Date(new Date(), 'America/Los_Angeles'); should work

pixelfreak commented 11 years ago

Oh, interesting! That was giving me an error before, but now I see that I was doing it wrong. Thanks!

longlho commented 11 years ago

Sure np :)