-3

In python I can use time.time() to get this:

time = time.time()
time = 1362914221

How do I get this in java-script?

time = ????
Jan Hančič
  • 53,269
  • 16
  • 95
  • 99
Tampa
  • 75,446
  • 119
  • 278
  • 425
  • 1
    A good question would have not been "like in Python" but would have specified what exactly was required (seconds since epoch for example). – Denys Séguret Mar 18 '13 at 08:03

2 Answers2

6

You can use

time = (new Date()).getTime() / 1000;

See getTime() on the MDN.

Denys Séguret
  • 372,613
  • 87
  • 782
  • 758
3

Just like this:

var time = +new Date;
Renjith
  • 5,783
  • 9
  • 31
  • 42