You need to sign in to do that
Don't have an account?
Miranda L 2
I tried to check Datetime.now() or System.now() gives incorrect time
Hi there,
I wondering when I tried to check to find out my current date then it gives me 2 hours back time.
Datetime cDT = System.now();
system.debug('Date Time: '+cDT);
String LongDate = cDT.format('EEEE, MMMM d, yyyy');
system.debug('long Date: '+LongDate);
datetime d = Datetime.now();
system.debug('d: '+d);
why my current time is not showing. I have checked the company information which is the exact my location but still the time showing 2 hours back. Please guide me.
I wondering when I tried to check to find out my current date then it gives me 2 hours back time.
Datetime cDT = System.now();
system.debug('Date Time: '+cDT);
String LongDate = cDT.format('EEEE, MMMM d, yyyy');
system.debug('long Date: '+LongDate);
datetime d = Datetime.now();
system.debug('d: '+d);
why my current time is not showing. I have checked the company information which is the exact my location but still the time showing 2 hours back. Please guide me.
Salesforce stores the time in UTC. If you want to change 'GMT' then I suggest using the below code to convert.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
All Answers
Please check the locale Timezone in your User record.
I have debug to see again but it showing
If you see the Debug my time 14:11:33:003 but showing in debug 12:11:33
timezone is also correct according to timezone
please guide me
Salesforce stores the time in UTC. If you want to change 'GMT' then I suggest using the below code to convert.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
Thank you
You can also check the below code If you want to change 'GMT'.