3

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 = ????
9
  • new_date = new Date((now_utc * 1) + offset) Commented Aug 3, 2016 at 6:29
  • No its giving me the same UTC date... Commented Aug 3, 2016 at 6:35
  • I disagree, it's the same date plus 330 - for example, I get now_utc = 2016-08-02T20:36:35.000Z and new_date=2016-08-02T20:36:35.330Z ... see how they differ by exactly 330 Commented Aug 3, 2016 at 6:36
  • @JaromandaX I tried it in console... Here is what I got... new Date(now_utc) Wed Aug 03 2016 06:40:14 GMT+0530 (India Standard Time) new Date((now_utc * 1) + 330) Wed Aug 03 2016 06:40:14 GMT+0530 (India Standard Time) Commented Aug 3, 2016 at 6:44
  • 1
    You wanted to add 330. Only now do you imply you meant minutes. I don't read minds Commented Aug 3, 2016 at 8:16

1 Answer 1

3
new_date = new Date((now_utc * 1) + (330*60*1000))
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.