3

I'm working on learnyounode module 13 right now. In the hints section it claims "Date#getTime() will also come in handy."

I looked up the Date object and found the getTime method, but what does it mean when there's a hash instead of a period?

ajHurliman
  • 147
  • 2
  • 15

2 Answers2

7

This is just a refference to getTime method of Date object. It is normal syntax when you talk about documentations.

According to EcmaScript specification it returns this time value (the number of milliseconds since 1 January 1970 00:00:00 UTC.).

Boris Zagoruiko
  • 12,705
  • 15
  • 47
  • 79
  • It's basically the same as a Unix Timestap but with millisecond precision. You can get the current Unix Timestap with `new Date().getTime() / 1000` – dusky Oct 21 '14 at 08:37
  • There is nothing about Unix in question? What is the goal of your comment? – Boris Zagoruiko Oct 21 '14 at 09:31
  • 1
    I think @dusky meant that dividing the return value of `getTime` by 1000 is the equivalent of a UNIX timestamp (or Epoch time) – moonthug Oct 21 '14 at 16:04
  • I didn't mention it in the question, but the learnyounode problem asks you to get the Epoch time. – ajHurliman Oct 21 '14 at 18:52
  • 2
    It's worth noting that `Date.now()` is quite a lot faster than `+new Date()` or `new Date().getTime()`. If you care about speed or memory collection jitter you should avoid `new Date()`. For a benchmark see: http://jsperf.com/date-now-vs-new-date-gettime/14 Note: the versions with lower-case date assume that the date doesn't change which isn't applicable in most circumstances. The same applies with nodejs. Hope that helps. – Max Murphy Aug 18 '15 at 15:33
0

getTime function return unix timestamp

let nd = new Date();
let currentTime = nd.getTime();
console.log(currentTime);
javed
  • 406
  • 3
  • 10