How can I add exta 1hour to a timestamp
for example, 1574620200000 (With Micro Seconds)
this is my date in the format of timestamp, can i add a number with the timestamp to increase time to extra 1 hour.
How can I add exta 1hour to a timestamp
for example, 1574620200000 (With Micro Seconds)
this is my date in the format of timestamp, can i add a number with the timestamp to increase time to extra 1 hour.
Share Improve this question asked Nov 14, 2019 at 11:52 Lijo VijayanLijo Vijayan 852 silver badges9 bronze badges 04 Answers
Reset to default 4You can just add 60 * 60 * 1000
;)
You could add (60*60*1000)
with your time
1 sec = 1000 ms 1 min = 60 sec 1 hr = 60 min
const t = new Date();
t.setTime(1574620200000+(60*60*1000));
console.log(t)
Yes an hour in microseconds is equal to 3600000000
, so all you have to do is add that hour in microseconds to the existing time,
var time = 1574620200000;
var hour = 3600000000;
var newTime = time + hour;
Another option if you're working with Date
s is using getHours()
and setHours()
:
const now = new Date();
console.log(now);
now.setHours(now.getHours() + 1);
console.log(now);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744204399a4563031.html
评论列表(0条)