Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript add one minute to time object

I have a date string that looks like the following javascript format. I want to convert this to a date object and add one minute.

timeObject = "Mon Nov 07 2011 06:41:48 GMT-0500 (Eastern Standard Time)";


timeObject.setSeconds(timeObject.getSeconds() + 60);

====== SOLUTION ==========

never mind. I got it...

var time = $('#myDiv').val();     // = "Mon Nov 07 2011 06:41:48 GMT-0500 (Eastern Standard Time)";
var timeObject = new Date(time);                
alert(timeObject);
timeObject.setSeconds(timeObject.getSeconds() + 60);    
alert(timeObject);
like image 857
Mustapha George Avatar asked Nov 07 '11 11:11

Mustapha George


1 Answers

Proper way is:

timeObject.setTime(timeObject.getTime() + 1000 * 60);
like image 103
Shadow Wizard Hates Omicron Avatar answered Sep 21 '22 05:09

Shadow Wizard Hates Omicron