admin管理员组

文章数量:1290307

I want to subtract 5.30 hours from a date, for example, I have a date:

Fri Jan 15 2016 00:00:00 

after subtraction, it should be something like,

Thu Jan 14 2016 19:30:00

How I can achieve this. Any help will be appreciated.

I want to subtract 5.30 hours from a date, for example, I have a date:

Fri Jan 15 2016 00:00:00 

after subtraction, it should be something like,

Thu Jan 14 2016 19:30:00

How I can achieve this. Any help will be appreciated.

Share Improve this question asked Feb 17, 2016 at 7:10 VishAlVishAl 3783 silver badges17 bronze badges 1
  • Are both times in local time? If so, is it ok to return 4 1/2 hours or 6 1/2 hours diff if the time interval overlaps a DST shift? – Joachim Isaksson Commented Feb 17, 2016 at 7:14
Add a ment  | 

1 Answer 1

Reset to default 10

try

var date = new Date("Fri Jan 15 2016 00:00:00");
date.setHours(date.getHours()-5);
date.setMinutes(date.getMinutes()-30);

本文标签: datetimewant to substract 530 hours from a Date javascriptStack Overflow