javascript - Typescript: Add extra one hour to timestamp - Stack Overflow

How can I add exta 1hour to a timestamp for example,1574620200000 (With Micro Seconds)this is my date

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 0
Add a ment  | 

4 Answers 4

Reset to default 4

You 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 Dates 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

相关推荐

  • javascript - Typescript: Add extra one hour to timestamp - Stack Overflow

    How can I add exta 1hour to a timestamp for example,1574620200000 (With Micro Seconds)this is my date

    8天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信