문제

I'm making HTML5 canvas application. For animation, I need high resolution clock time. How can I get this? It should be millisecond level resolution at minimum.

도움이 되었습니까?

해결책

AFAIK, this isn't part of HTML5 but JavaScript. And you can't do this reliably since it depends on the browser implementation. For example, in IE (8 and 6), the smallest resolution you can have is 15 milliseconds.

Update

Apologies - I just noticed you asked how to actually get the time, use Date.getTime(). This will give you the time in milliseconds since 1st Jan, 1970 but my caveat from above still stands - you'll get a value in milliseconds but you cannot be sure of the accuracy and so you shouldn't depend on this for anything time critical.

References:

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top