How to find minutes, seconds and Milliseconds difference between two datetime in Salesforce?

getTime() in Salesforce is used to get milliseconds from a Datetime.

Sample Code:

DateTime maxTime =;
DateTime minTime =;
system.debug('Milliseconds Difference is ' + (maxTime.getTime() - minTime.getTime()));
system.debug('Seconds Difference is ' + (maxTime.getTime() - minTime.getTime()) / 1000);
system.debug('Minustes Difference is ' + (maxTime.getTime() - minTime.getTime()) / 60000);



No comments:

Post a Comment

Sharing is Caring!!! Share this with your friends!!!

submit to reddit