adjust-timezone

1.0.2 • Public • Published

adjust-timezone

This is for adjust date time while sending and receiving date time in different time zone

Install

$ npm i adjust-timezone

Usage

client-side: get timezone offset with getTimezoneOffset() and send to server woth API

const clientOffset = new Date().getTimezoneOffset(); 
const clientDate = from_client;

Date from client to server then direction = 'CLIENT_TO_SERVER'

Date from server to client then direction = 'SERVER_TO_CLIENT'

Default direction = 'SERVER_TO_CLIENT'

server-side: Send date time from client to server

const { adjustTimezone } = require("adjust-timezone");

const direction = 'CLIENT_TO_SERVER'
const inServerTimeDate = adjustTimezone(clientDate, clientOffset, direction)

server-side: Send date time from server to client

const { adjustTimezone } = require("adjust-timezone");

const direction = 'SERVER_TO_CLIENT'
const inClientTimeDate = adjustTimezone(clientDate, clientOffset, direction)

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    0
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i adjust-timezone

Weekly Downloads

0

Version

1.0.2

License

ISC

Unpacked Size

3.88 kB

Total Files

6

Last publish

Collaborators

  • vipulvyas