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 

Salesforce MVP | Lightning Champion | 17x Salesforce Certified | Application Architect | 7x Trailhead Ranger | Techforce Services | Australia

Leave a Reply

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