Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Math 1

Status
Not open for further replies.

CassidyHunt

IS-IT--Management
Joined
Jan 7, 2004
Messages
688
Location
US
I know this is simple but I want to add 30 seconds to the current date and time so I can set that as the expiration for a cookie. Here is my current algorythm. It doesn't add anytime at all.

Code:
function CheckDate() {
		var _test = new Date();
		var _test2 = new Date();
		
		_test2.setDate(_test.getDate() + (30 * (1/24/60/60)));
		alert(_test.toUTCString() + "\n30 Seconds Later\n" + _test2.toUTCString());
		

	}

Thanks

Cassidy
 
i would do something like this:

Code:
var _test = new Date();
var _test2 = new Date(_test);
_test2.setTime(_test2.getTime()+30000);
alert(_test.toUTCString() + "\n30 Seconds Later\n" + _test2.toUTCString());

*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
Thanks. Funny how every langauage handles dates. They are all drastically different.
 
Funny how every langauage handles dates. They are all drastically different.

Surely it's because languages are different to each other that the underlying code and ways of doing things are different.

I'd be more worried if every language did things in the same way - then there would be no point in having different langauges!

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top