How to convert DateTime to UTC time using Apex Class?

Difference Between GMT and UTC:
The Difference Between GMT and UTC. Greenwich Mean Time (GMT) is often interchanged or confused with Coordinated Universal Time (UTC). But GMT is a time zone and UTC is a time standard. The Royal Observatory in the UK. The Royal Observatory in Greenwich, London, United Kingdom.

public DateTime getUTCDateTime(DateTime dt){
Datetime GMTDate = Datetime.newInstanceGmt(
return GMTDate;

System.debug(‘UTC time ‘+getUTCDateTime(;
Refer DateTime methods:

Written by 

2x Salesforce MVP | Platform Champion | 18x Salesforce Certified | MuleSoft Certified | 8x Trailhead Ranger | TechForce Services | Sydney | Australia

Leave a Reply

Your email address will not be published. Required fields are marked *