adjust-timezone
v1.0.2
Published
adjust client to server and server to client timezone
Downloads
1
Readme
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)