Displaying date/time in user's timezone - on client side

后端 未结 3 797
没有蜡笔的小新
没有蜡笔的小新 2020-12-06 07:31

I have a web application that displays datetime stamps on every page, for example:

December 12, 2009 6:00 pm

I would like to dyn

3条回答
  •  一个人的身影
    2020-12-06 07:53

    Here is how you could do it with the wonderful "progressive enhancement":

    Output the date where you want it to appear, but be sure to specify its timezone (I use GMT here, but you could use UTC, etc). Then swap it out with the local time on load (Automatically handled by JavaScript if the original timezone is provided).

    December 12, 2009 6:00 pm GMT

提交回复
热议问题