date-tz

Wrapper above js native Date object for using with time zones that differs from current

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
date-tz
0.1.24 years ago4 years agoMinified + gzip package size for date-tz in KB

Readme

constructor

Wrapper above js native Date object for using with time zones that differs from current
Parameters
  • zone string1 zone2 (optional, default '+0000')
  • args any any data to initialize native date3 object

Examples
import DateTz from 'DateTz';
const date = new DateTz('+0300', '2000-01-01T00:00:00.000Z');
i.toISOString(); // '2000-01-01T00:00:00.000Z'

zone

Parameters

Examples
import DateTz from 'DateTz';
const i = new DateTz('+0000', '2000-01-01T00:00:00.000Z');
i.zone // '+0000';
i.getTzHours(); // 0
i.getUTCHours(); // 0
i.zone = '+0300';
i.zone; // '+0300'
i.getTzHours(); // 3
i.getUTCHours(); // 0

getTzDate

returns date in zone2
Examples
import DateTz from 'DateTz';
const i = new DateTz('+06', '2000-01-10T00:00:00.000+06:00');
i.setTzDate(12);
i.getTzDate(); // 12
i.getUTCDate(); // 13

Returns number5

getTzDay

returns day of week in zone
2
Examples
import DateTz from 'DateTz';
const i = new DateTz('06', '2000-01-10T00:00:00.000+06:00');
i.setTzDate(12);
i.getTzDay(); // 3
i.getUTCDay(); // 2

Returns number5

getTzFullYear

returns year in zone
2
Examples
import DateTz from 'DateTz';
const i = new DateTz('+06', '2000-01-01T00:00:00.000+06:00');
i.setTzFullYear(2002);
i.getTzFullYear(); // 2002
i.getUTCFullYear(); // 2001

Returns number5

getTzHours

returns hours in zone
2
Examples
import DateTz from 'DateTz';
const i = new DateTz('-06', '2000-01-01T06:00:00.000Z');
i.getTzHours(); // 0
i.setTzHours(2);
i.getTzHours(); // 2
i.getUTCHours(); // 8;

Returns number5

getTzMilliseconds

returns milliseconds in zone
2
Examples
import DateTz from 'DateTz';
const i = new DateTz('-06', '2000-01-01T00:00:00.000Z');
i.setTzMilliseconds(15);
i.getTzMilliseconds(); // 15
i.getUTCMilliseconds(); // 15

Returns number5

getTzMinutes

returns minutes in zone
2
Examples
import DateTz from 'DateTz';
const i = new DateTz('-0603', '2000-01-01T06:00:00.000Z');
i.setTzMinutes(15);
i.getTzMinutes(); // 15
i.getUTCMinutes(); // 18

Returns number5

getTzMonth

returns month in zone
2
Examples
import DateTz from 'DateTz';
const i = new DateTz('-06', '2000-01-30T20:00:00.000-06:00');
i.setTzMonth(5);
i.getTzMonth(); // 5
i.getUTCMonth(); // 6

Returns number5

getTzSeconds

returns seconds in zone
2
Examples
import DateTz from 'DateTz';
const i = new DateTz('-06', '2000-01-01T00:00:00.000Z');
i.setTzMilliseconds(15);
i.getTzMilliseconds(); // 15
i.getUTCMilliseconds() // 15

Returns number5

getTzTimezoneOffset

returns offset between zone
2 and UTC
Examples
import DateTz from 'DateTz';
i = new DateTz('-0507', '2000-01-30T20:00:00.000-06:00');
i.getTzTimezoneOffset(); // 307

Returns number5

setTzDate

set date in zone
2

setTzFullYear

set year in zone2

setTzHours

set hours in zone2

setTzMilliseconds

set milliseconds in zone2

setTzMinutes

set minutes in zone2

setTzMonth

set month in zone2

setTzSeconds

set seconds in zone2

Installation

npm install --save DateTz