Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
197 views
in Technique[技术] by (71.8m points)

javascript - 从给定日期时间更新datetime(update datetime from given datetime)

I need to update every second a given datatime.(我需要每秒更新给定的数据时间。)

It's not necessary a today date, that can be "October 11, 2017 08:01:29"(今天的日期没有必要,可以是“ 2017年10月11日08:01:29”) Something like this I suppose, but I lack of elements.(我想是这样的,但是我缺乏元素。) var dte = new Date("October 11, 2017 08:01:29"); setInterval('test()', 1000); function test(){ //update date "dte" console.log(dte) }   ask by KasaiJo translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try this:(尝试这个:)

var dte = new Date("October 11, 2017 08:01:29").getTime(); setInterval('test()', 1000); function test() { dte = dte + 1000; console.log(new Date(dte)); }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...