Subtract 5 minutes from DateTime Object in Apex #inSalesforce

Use the following in Apex:


DateTime dt = System.now();

DateTime fiveMinutesBefore = dt.addMinutes(-5);

System.debug(dt + '\t' + fiveMinutesBefore);


Comments