2.1.2 • Published 9 years ago

tz2tz v2.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

Build Status

Disclaimer

Honestly I'm just writing this so that I can require it without relative file paths in my projects.

If you find it useful, great. Otherwise, like all open-source software, expect zero support.

I will happily merge PRs though :)

API

// I recommend 'z' because 't' is a common temp var name
var z = require('tz2tz')
  , timestamp = Date.now()

// Parse the timestamp in the timezone then output it in the moment-style format specified
z(timestamp, 'America/Los_Angeles', 'ddd MMM D')

// Shorthandy goodness

// Thu Jan 15
// Uses 'ddd MMM D' as format
z.getDate(timestamp, 'America/Los_Angeles')

// 6:05AM
// Uses 'h:mmA' as format
z.getTime(timestamp, 'America/Los_Angeles')

// 6:05AM 1/15/15
z.getShort(timestamp, 'America/Los_Angeles')

// Thu, Jan 15, 2015 6:05 AM
// Uses preferred locale format
z.getFull(timestamp, 'America/Los_Angeles')

// Thursday
z.getDay(timestamp, 'America/Los_Angeles')

// 6 (integer)
z.getHours(timestamp, 'America/Los_Angeles')

// 5 (integer)
z.getMinutes(timestamp, 'America/Los_Angeles')

// Change the shorthand constants
z.constants.timeFormat = 'h:mm a'

Is That All?

Yeah that's it. But seriously, if you had to do this hundreds of times, you would want something like this too.

2.1.2

9 years ago

2.1.1

9 years ago

2.1.0

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.2.2

9 years ago

1.2.1

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago