views:

25

answers:

3

Hi I'm passing a unixtimestamp to a javascript IF statement, can anyone tell me how to generate a unixtimestamp one minute in the future with javascript.

Anyhelp would be helpful.

Thanks

+1  A: 

UNIX time is just the number of seconds since 1970-01-01Z. So just add 60 you'll get a timestamp one minute later.

Joey
+1  A: 

JavaScript Date object's getTime returns the number of milliseconds since midnight Jan 1, 1970.

Try this.

var oneMinLater = new Date().getTime() + 60 * 1000;
var d = new Date();
d.setTime(oneMinLater);
Alex Cheng
+1  A: 

The JavaScript Date object has a getTime() method that returns milliseconds since 1970. To make this look like a UNIX timestamp, you need to divide by 1000 and round (with Math.floor()). Adding 60 get's your one minute ahead.

var d = new Date();
var unixtimeAdd60 = Math.floor(d.getTime()/1000)+60;
Gavin Brock
Thanks for the code works perfect!
cocacola09