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);
正确的做法是:
timeObject.setTime(timeObject.getTime() + 1000 * 60);
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.