Hacker News new | past | comments | ask | show | jobs | submit login

new Date () returns creates a JavaScript date object.

When coerced to a number, it's the number of milliseconds since January 1, 1970.

If you wanted to know the number of seconds since January 1, 1970, you could divide by 1000. Since JavaScript will do the coercion for you automatically you can pretty much treat a date object as if it were a number.

This is basically a utility routine that I use for debugging messages to say how long an operation took.

Here's an example of its use:

https://github.com/scripting/myWordEditor/blob/master/script...

It's especially nice because JavaScript automatically does real arithmetic on the division, so you get fractions of seconds displayed in the console.

I use this routine a lot. Helps me spot performance problems. Nice to have, not a crucial routine.

Hope this helps! ;-)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: