How to convert UTC time to Local time in Dynamics 365 using JavaScript

 How to convert UTC time to Local time in Dynamics 365 using JavaScript


The input startTime and endTime are both UTC time.

   // Convert to local time

    var utcStartTime = new Date(startTime);

    var utcEndTime = new Date(endTime);

    

    var localStartTime = new Date(utcStartTime.getTime() + utcStartTime.getTimezoneOffset() * 60000);

    var localEndTime = new Date(utcEndTime.getTime() + utcEndTime.getTimezoneOffset() * 60000);

  

No comments:

Post a Comment