Are Javascript date/time functions dependent on the client machine?

后端 未结 5 1449
孤独总比滥情好
孤独总比滥情好 2020-12-30 06:50

I was wondering if Javascript date/time functions will always return correct, universal dates/times or whether, Javascript being a client-side language, they are dependent

5条回答
  •  别那么骄傲
    2020-12-30 07:33

    As thomasrutter has said javascript date functions are reliant on the client's machine. However if you want to get an authoritative date you could make and ajax request to your server that just returns the date string. You can then convert the date string into a date object with the following

    var ds = ... // Some ajax call
    var d = new Date(ds);
    

提交回复
热议问题