Introduction
Blogs need to display publishing time, restaurant websites need to display reservation time, and auction websites need to display various order times. No matter what you do, you will encounter the very common need to display time.
This problem seems simple, just display the time, right? But if it involves “time zones”, the problem will become even more complicated. Regarding time zones, there are usually several requirements:
- The time on the website needs to be displayed in a fixed time zone. I want to see the same time on the website whether I am in the United States or in Taiwan.
- The time on the website will be different according to the user’s browser settings. I will see different times in the United States and Taiwan.
- PM did not consider this issue and only considered local users, so there is no need to worry about this for the time being.
And this is only the display part. There is another part that communicates with the backend. We can talk about this later, but in any case, correctly handling time and time zones is not a simple matter.
I have recently encountered related issues in one or two jobs, so I have a little experience in this area and wrote this article to share with you.