Modifying dateString as per UTC-Offset to satisfactorily filter based on date

let offset =new Date().getTimezoneOffset() 
// will return -330 in India where timezone is GMT+5:30
// will return 480, in USA where timezone is GMT-8
Further we use moment library to modify the date code is as followsimport moment from 'moment-timezone'function addOffsetCorrection(dateString:string):string {
let offset =new Date().getTimezoneOffset();

return moment(dateString).add(offset,'minutes').format('DD/MM/YYYY HH:mm:ss')

// changes '2020:10:20T00:00:00' to '2020:10:19T20:30:00Z' for India
// changes '2020:10:20T00:00:00' to '2020:10:20T08:00:00Z' for USA




I love learning

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Creating Secondary Entry Points for your Angular Library

Stuck in JavaScript

How to get Unique Values from array in JavaScript

Relating ReactJS to everyday concepts

Snake Game with JavaScript

Element of Unknown Height with Text of Varying length

Anna Coding Front-end Reading in Depth Week — 20

Extract key value and Index of Non-iterable object

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Akshay Jain

Akshay Jain

I love learning

More from Medium

DeSyfers’ first workation

Design for Understanding

10 Usability Heuristics for User Interface Design

How I improved my blog writing?