function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sgsg 

Datetime format issue in the UI and Apex/Developer console.

Hi
I have a custom DATETIME field Submitted date__c in the custom object and it captures the date and time when the status is changed to Submitted. The issue here is I am seeing GMT-4 time (14:00 ) in UI and in the Developer console and apex logs, its showing GMT time (18:00). I have a number field which gets increased everday based on this submitted datetime if is its greater than 14:00 on the UI. Since I am seeing different times, I cannot come to a conclusion. Help needed.
SwethaSwetha (Salesforce Developers) 
HI Sangeetha,
Your ask looks similar to https://salesforce.stackexchange.com/questions/344357/datetime-format-in-the-ui-and-db according to which

The UI format is just a more user-friendly format, shown in your preferred timezone, converted from GMT on the back end.
The results of your query are the IS0-8601 format, how it is stored on the back end.
The output of your Apex code is the default formatting of the Datetime primative data type.


Additional Resource on Datetime methods on Apex: https://developer.salesforce.com/docs/atlas.en-us.232.0.apexref.meta/apexref/apex_methods_system_datetime.htm

To troubleshoot this issue, you can try the following steps:

1. Check the timezone settings for your user profile: Go to Setup > Personal Information > My Personal Information > Advanced User Details, and check the "Locale" and "Time Zone" fields. Make sure they are set correctly for your location.
2. Check the timezone settings for your org: Go to Setup > Company Settings > Time Zone, and make sure it is set correctly for your location.
3. Check the timezone settings for your developer console: Go to Debug > Change Log Levels > System, and make sure the "DebugLevel" object has the correct timezone set.
4. Use the DATETIMEVALUE() function in your formula: This function can help you standardize the timezone of your Datetime values in your formula field. For example, you can use DATETIMEVALUE(TEXT(Submitted_date__c)) to convert the Submitted_date__c field to a Datetime value in the UTC timezone.
5. Use the TimeZone class in your Apex code: You can use the TimeZone class to convert Datetime values between timezones in your Apex code. For example, you can use the getTimeZone() method to get the user's timezone, and the format() method to format the Datetime value in the user's timezone.

If this information helps, please mark the answer as best. Thank you
sgsg
Hi Swetha,

I have already checked that link you've provided. All the Timezones are set to GMT-4, Its displayed likewise in UI and Salesforce is capturing it in UTC. 
I am capturing the Submitted_date__c field using a flow global variable Currentdatetime upon the condition Status = ISCHANGED AND Equals Submited. How can i achieve "to convert the Submitted_date__c field to a Datetime value in the UTC timezone" this in flow? 

Also, If we convert the UI time to UTC as same as Salesforce, Can i fix my issue in that way? Assist me.

Thanks in advance.