[SalesForce] How to get the current timestamp using SOQL query

I want to know the timezone of the timestamp value in systemmodstamp column in my SF objects.

Best Answer

Date values are stored in UTC time format in Salesforce, the timezone is only applied when the date is displayed. If you are in Apex, you can use the various methods it provides to return an automatically adjusted value or the GMT value.

Remember that dateTime field values are stored as Coordinated Universal Time (UTC). When one of these values is returned in the Salesforce application, it is automatically adjusted for the timezone specified in your organization preferences. Your application may need to handle this conversion.

You can retrieve the current time zone using the UserInfo class.

TimeZone tz = 
  UserInfo.getTimeZone();
System.debug(
  'Display name: ' + 
  tz.getDisplayName());
System.debug(
  'ID: ' + 
  tz.getID());
Related Topic