I have a particular system configuration where my timezone is setted at (UTC-03:00) but I configured the system time to an hour after (e.g: Originally my time using the timezone must be 14:41, but I updated to 15:41).
What I want to know if there is a way using any library to know that the time is not correlated with the timezone.
Other solution could be to resolve the time using moment or other library returning the time using the system timezone and not the system time.
I tired using Date or moment with moment-timezone with no luck.
E.g:
System Time: 15:46 (+1 Hour configured manually)
Timezone Time: 14:46 (This should be the hour if isn't updated)
moment() //result Wed Nov 17 2021 15:46:19 GMT-0300
What I want is
moment().someFunc() //result Wed Nov 17 2021 14:46:19 GMT-0300
// Could be a function, property, just a difference to use it in order
//to compare with other date that comes from the server
If you try to get the utc date time (with moment().utc()) the result is your time less utcOffset and there isn't somthing about that in the documentation, so I think there isn't a way to do what do you want.
an alternative is to get the time from a external server like code bellow, but I hope for you that someone else know a way better
async function myTzTime() {
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
const { data: { datetime } = {} } = await axios.get(`http://worldtimeapi.org/api/timezone/${timezone}`);
console.log('--->', datetime)
}
myTzTime();
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.24.0/axios.min.js"></script>