Get UTC time in IST

 Below is the code snippet which helps to get UTC date and time in Indian Standard Time (+5.30)


System.TimeZoneInfo timeZone = System.TimeZoneInfo::FindSystemTimeZoneById("India Standard Time");

 System.DateTime localTime = System.TimeZoneInfo::ConvertTimeFromUtc(System.DateTime::UtcNow, timeZone); // Convert from utc to IST.

 Info(strFmt("Local Time: %1", localTime.ToString("MM/dd/yyyy")));

 Info(strFmt("Local Time: %1", localTime.ToString("dddd, dd MMMM yyyy")));

 Info(strFmt("Local Time: %1", localTime.ToString("MMMM dd")));

 Info(strFmt("Local Time: %1", localTime.ToString("dddd, dd MMMM yyyy HH:mm:ss")));

 Info(strFmt("Local Time: %1", localTime.ToString("MM/dd/yyyy HH:mm")));

 Info(strFmt("Local Time: %1", localTime.ToString("MM/dd/yyyy hh:mm tt")));

 Info(strFmt("Local Time: %1", localTime.ToString("MM/dd/yyyy H:mm")));

 Info(strFmt("Local Time: %1", localTime.ToString("yyyy’-‘MM’-‘dd’T’HH’:’mm’:’ss.fffffffK")));

 Info(strFmt("Local Time: %1", localTime.ToString("ddd, dd MMM yyy HH’:’mm’:’ss ‘GMT")));

 Info(strFmt("Local Time: %1", localTime.ToString("yyyy’-‘MM’-‘dd’T’HH’:’mm’:’ss")));

 Info(strFmt("Local Time: %1", localTime.ToString("")));

 Info(strFmt("Local Time: %1", localTime.ToString("MM-dd-yyyy")));

Popular posts from this blog

Send Purchase Orders to Vendor collaboration for Vendor Review in D365FO

Export Data Packages using Data Management and Postman in D365FO

Remove Prefix from a String in D365FO