You need to sign in to do that
Don't have an account?
sfadm sfadm
How can I get my correct current local time?
I need to get the current time but to be in type DateTime.
I use:
I execute the code in 2017-08-04 00:38:46 AM
but it returns
I had even tried with:
I use:
DateTime now = System.now();but it returns wrong time.
I execute the code in 2017-08-04 00:38:46 AM
but it returns
00:38:46:023 USER_DEBUG [138]|DEBUG|now 2017-08-03 21:38:46How can I get my correct current local time 2017-08-04 00:38:46?
I had even tried with:
DateTime now = DateTime.parse(System.Now().format());but I still get wrong time.
01:10:09:021 USER_DEBUG [139]|DEBUG|now 2017-08-03 22:10:00How can I get the correct current local time?
All Answers
Your code is good but to get the current DateTime format you have to use below code.
you can also change the format as you like
here is the sample code:
Thanks
Pramodh
<pre>
DateTime now = System.now();
System.debug( 'now ' + now.format( 'yyyy-MM-dd HH:mm:ss' );
</pre>
Datetime now = Datetime.now();
Integer offset = UserInfo.getTimezone().getOffset(now);
Datetime local = now.addSeconds(offset/1000);
I want to use the below formula in a workflow rule:
Datetime now = Datetime.now();
Integer offset = UserInfo.getTimezone().getOffset(now);
Datetime local = now.addSeconds(offset/1000);
I am writing the formula in Workflow as:-
now.addSeconds(
UserInfo.getTimezone().getOffset(Datetime.now())/1000
)
but it is showing some error
How can I resolve this?