Sunday 18 September 2022

All About "Time" in Java Script

 



While using date & time we always want to display time in local time, for example india is GMT + 5:30.

But what's GMT and UTC ?




For programmers building business-oriented apps, the upshot is that UTC is the new GMT. You can use the terms interchangeably, with the difference being literally less than a second. So for all practical purposes in most apps, no difference at all.


How do we store time ?

In computer we store time at 32-bit interger which is linux UTC epoch time. 

Try this code :

From where Time zone is decided ?

Time zone comes seperately from local setting either from your computer setting or mobile setting.
So based on you want to display local time ? or UTC time ? javascript convert epoch time into suitable string.

Firebase timestamp vs Javascript Date :





No comments:

Post a Comment