Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add offset to UTC date in Javascript

I have UTC date and want to add offset say 330 minutes to it.

var now = new Date(); 
var now_utc = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(),  now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds());
var offset = 330;

var new_date = ????
like image 480
Abhijit Borade Avatar asked Feb 03 '26 01:02

Abhijit Borade


1 Answers

new_date = new Date((now_utc * 1) + (330*60*1000))
like image 108
Abhijit Borade Avatar answered Feb 12 '26 16:02

Abhijit Borade



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!