utc time to local time

Discuss RoboTask here
Post Reply
rgonzalez
Posts: 41
Joined: Fri Nov 26, 2010 10:19 am

utc time to local time

Post by rgonzalez »

Is there a way to convert UTC datetime to local datetime?

Thank you!
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: utc time to local time

Post by Oleg »

You can do this with javascript. Use methods of Date object
See the example (task) below:

Code: Select all

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|317955339
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task1144"
Hide=INTEGER|0
ID=INTEGER|33281083
LogOnAsUser=INTEGER|1
Name=STRING|"JS script..."
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER

[Actions\Action1]
ActionID=STRING|"A_SCRIPT_JSSCRIPT"
Enabled=INTEGER|-1
Name=STRING|"JS script"
Params=FOLDER

[Actions\Action1\Params]
expandvars=STRING|"0"
line00000000=STRING|"d = new Date();"
line00000002=STRING|"logmessage('GMT offset= ' + d.getTimezoneOffset() + ' minutes');"
line00000004=STRING|"logmessage('****************');"
line00000006=STRING|"logmessage(d.toGMTString());"
line00000007=STRING|"logmessage(d.toString());"
line00000008=STRING|"logmessage(d.toLocaleString());"
line0000000A=STRING|"logmessage('****************');"
line0000000C=STRING|"d = new Date(2015, 4, 14, 9,0,0);"
line0000000D=STRING|"logmessage(d.toGMTString());"
line0000000E=STRING|"logmessage(d.toString());"
line0000000F=STRING|"logmessage(d.toLocaleString());"
linecount=STRING|"17"
savescript=STRING|"0"
The script is:

Code: Select all

d = new Date();

logmessage('GMT offset= ' + d.getTimezoneOffset() + ' minutes');

logmessage('****************');

logmessage(d.toGMTString());
logmessage(d.toString());
logmessage(d.toLocaleString());

logmessage('****************');

d = new Date(2015, 4, 14, 9,0,0);
logmessage(d.toGMTString());
logmessage(d.toString());
logmessage(d.toLocaleString());
Oleg Yershov
Post Reply