我有一个类似于以下javascript格式的日期字符串。 我想将其转换为日期对象并添加一分钟。
timeObject = "Mon Nov 07 2011 06:41:48 GMT-0500 (Eastern Standard Time)";
timeObject.setSeconds(timeObject.getSeconds() + 60);
======解决方案==========
没关系。我明白了......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);
答案 0 :(得分:23)
正确的方法是:
timeObject.setTime(timeObject.getTime() + 1000 * 60);