Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to get time zone difference date-fns

const dt = new Date('2017-12-12');
console.log(format(dt, 'YYYY-MM-DD'));
The above code logs 2017-12-11 in the US, but 2017-12-12 in India.
||||||||||||||||||====>
const dt = new Date('2017-12-11');
const dtDateOnly = new Date(dt.valueOf() + dt.getTimezoneOffset() * 60 * 1000);
console.log(format(dtDateOnly, 'YYYY-MM-DD')); // Always "2017-12-11"
Comment

PREVIOUS NEXT
Code Example
Javascript :: find if json property is of type date type 
Javascript :: display fetch response js 
Javascript :: javascript allow only numbers in input alert 
Javascript :: string javascript concatenation 
Javascript :: javascript regex insert string 
Javascript :: shopify routes 
Javascript :: javascript map replace key value 
Javascript :: js index to index 
Javascript :: react functional component example 
Javascript :: how to check if it is the current time day.js 
Javascript :: NodeJS Content-Type 
Javascript :: how to async javascript stack overflow 
Javascript :: escape character javascript 
Javascript :: stringy 
Javascript :: validator.js 
Javascript :: fill in javascript 
Javascript :: Movie-app using react 
Javascript :: window parent frames javascript 
Javascript :: email validation in javascript 
Javascript :: pass function with parameter as prop 
Javascript :: divisible check javascript 
Javascript :: set default value in dropdown angular 7 
Javascript :: Do not use forEach with async-await 
Javascript :: array method 
Javascript :: read more css js 
Javascript :: show password eye icon angular 9 
Javascript :: datepicker range npm reactjs 
Javascript :: queryselector multiple attributes 
Javascript :: arrow function example 
Javascript :: work with query string javascript 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =