-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 = ????
1
  • 1
    A good question would have not been "like in Python" but would have specified what exactly was required (seconds since epoch for example). Commented Mar 18, 2013 at 8:03

2 Answers 2

7

You can use

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

See getTime() on the MDN.

Sign up to request clarification or add additional context in comments.

Comments

3

Just like this:

var time = +new Date;

1 Comment

What does the +new syntax do here?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.