Format a date with timezone
JavaScript
Switch branches/tags
Clone or download
Latest commit 4cbb199 Oct 6, 2016
Permalink
Failed to load latest commit information.
.editorconfig tweaks Oct 6, 2016
.gitattributes Init Nov 30, 2015
.gitignore Init Nov 30, 2015
.travis.yml tweaks Oct 6, 2016
index.js add support to pass in an offset Oct 6, 2016
license Init Nov 30, 2015
package.json 1.1.0 Oct 6, 2016
readme.md add support to pass in an offset Oct 6, 2016
test.js add support to pass in an offset Oct 6, 2016

readme.md

tz-format Build Status

Format a date with timezone: 2015-11-30T10:40:35+01:00

Install

$ npm install --save tz-format

Usage

const format = require('tz-format');

format();
//=> '2015-11-30T10:40:35+01:00'

format(0);
//=> '2015-11-30T09:40:35+00:00'

format(new Date());
//=> '2015-11-30T10:40:35+01:00'

format(new Date(), 0);
//=> '2015-11-30T09:40:35+00:00'

format(new Date(2015, 11, 25, 11, 0, 0, 0), -1);
//=> '2015-12-25T09:00:00-01:00'

API

format([date], [offset])

input

Type: date
Default: new Date()

Date to be formatted.

offset

Type: number

Offset from UTC in hours.

License

MIT © Sam Verschueren