JavaScript time independent of client PC's time
Is there a way to 开发者_JAVA技巧get the current UTC time without relying on the time and timezone of the client's pc? I am not allowed to use PHP or anything from the server side for this (Using a hosted service and they only allow changing of HTML and addition of JavaScript. Not allowed to change PHP on the server.). Must be only done from the client side via JavaScript.
Thanks in advance for any suggestions / solutions.
If my question is not clear, please let me know what else would make it clearer and I will add those details.
Best regards, Tony.
No, JavaScript can only give you the client time, or a value provided by the server (e.g. a special hidden utcTime
input element). You have ruled out the latter.
However, for dynamic pages, document.lastModified
may be a close approximation to the current server time. This is based on the Last-Modified header.
精彩评论