-5

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č
  • 51,914
  • 16
  • 93
  • 99
Tampa
  • 69,424
  • 111
  • 266
  • 409
  • 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
  • 355,860
  • 83
  • 755
  • 726
3

Just like this:

var time = +new Date;
Renjith
  • 5,745
  • 9
  • 29
  • 42