• Vishwas Gagrani

Find out UTC minus random local time

There are times when you have a specific time in UTC. And you need to know how much ahead or behind your local time is in comparison to UTC. To know that you can simply use date.timezoneOffset that will output the number of minutes your time is ahead or behind as compared to the time in UTC.

var timeInUTC = Date.UTC(2019,6,10,13,0,0);

var d:Date = new Date();

trace(d.timezoneOffset/60); //converting to hours from minutes


But what if you need to know how much a random local time is ahead or behind the time in UTC. This is the way out.



var d:Date = new Date();

var localTimeInUTC =Date.UTC(d.fullYearUTC,d.monthUTC,d.dateUTC,d.hoursUTC,d.minutesUTC,d.secondsUTC);

var timeDifferenceInHours = (timeInUTC-localTimeInUTC)/(3600*1000)



1 view

Like what you see ?

Got an  idea ?

15 April 2019

Last updated on

Bangalore (Karnataka),  India

VishwasGagrani.services

 Get  job  done !

  • Facebook Social Icon
  • Twitter Social Icon
  • Google+ Social Icon
  • YouTube Social  Icon
  • Pinterest Social Icon