System and User Date and Date Time in Salesforce

Sample Code:

system.debug('System Date - ' + System.now().dateGMT() + ' Or ' + DateTime.now().dateGMT());
system.debug('User Locale Date - ' + Date.today() + ' Or ' + System.today());
system.debug('System Date Time - ' + System.now() + ' Or ' + DateTime.now());

system.debug('User Locale Date Time - ' + DateTime.now().format() + ' Or ' + System.now().format());

Output:


Cheers!!!

No comments:

Post a Comment