The below code gave me IST time date
const x=new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '')
Output: 2020-09-01 17:49:48
I want to get IST time instead of UTC which is
2020-09-01 23:20:48
How to get above output in node js.
The below code gave me IST time date
const x=new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '')
Output: 2020-09-01 17:49:48
I want to get IST time instead of UTC which is
2020-09-01 23:20:48
How to get above output in node js.
new Date().toLocaleString('en-US', {timeZone: 'Asia/Kolkata'})
Install moment package and write the following two lines code to solve the problem:
var moment = require('moment');
console.log(moment().format("YYYY-MM-DD HH:mm:ss"));