1.0.2 • Published 2 years ago

adjust-timezone v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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)
1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago