hour() and hourGMT() in Salesforce Apex

hour() and hourGMT() in Salesforce Apex

hour() method returns hour in the running user context.

hourGMT() returns the GMT hour value.

Sample Code:

DateTime objDateTime = DateTime.now();
System.debug(
    'Current User Time Zone(EST) Hour ' +
    objDateTime.hour()
);
System.debug(
    'Current User Time Zone Hour ' +
    objDateTime.hourGMT()
);

Leave a Reply