I'm trying to setup a default timezone for moment js
I already imported moment-timezone and use this code
var moment = require('moment-timezone');
moment.tz.setDefault('Asia/Taipei');
console.log(moment().format('YYYY-MM-DD'));
but when I change my local date in my laptop to April 22, 2022.
Which is April 21,2022 in taipei right now, the console log give me this
2022-04-22
can you help me set up moment timezone not by my local time but depending on the timezone declared
sorry for my poor english
The momentjs is working as it should. MomentJs basically gets the current time from computer and then formats it using the timezone you want. For example If you set your timezone to another country say India then the time in the console will be 2:30 extra. I hope you got it.
If you want time independent of User's Device then you should use Time Apis like https://worldtimeapi.org/api/timezone/Asia/Taipei and make ajax calls to update your time. Like i integrated on the link
Hope it helps.