javascript javascript向时间对象添加一分钟

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8036091/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 02:03:43  来源:igfitidea点击:

javascript add one minute to time object

javascripttime

提问by Mustapha George

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.

我有一个类似于以下 javascript 格式的日期字符串。我想将其转换为日期对象并添加一分钟。

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);

回答by Shadow Wizard is Ear For You

Proper way is:

正确的做法是:

timeObject.setTime(timeObject.getTime() + 1000 * 60);