Skip to content

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

License

Notifications You must be signed in to change notification settings

vipulvyas/adjust-timezone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

adjust-timezone

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

Status: Version

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)

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published