Time to timestamp

Discuss RoboTask here
Post Reply
george
Posts: 25
Joined: Sun Mar 25, 2018 3:02 pm

Time to timestamp

Post by george »

Hi, is there a way I can convert a time format to unix timestamp in milliseconds?

For example:
"10:00:00" on input will give me the timestamp "36000000" on output
"22:00:00" on input will give me the timestamp "79200000" on output

:roll:

Thanks
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Time to timestamp

Post by Oleg »

Look at my example below
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task247"
Hide=INTEGER|0
ID=INTEGER|1336886879
LogOnAsUser=INTEGER|1
Name=STRING|"timestamp"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""TM"" with value ""10:30:25"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"TM"
varvalue=STRING|"10:30:25"

[Actions\Action2]
ActionID=STRING|"A_SCRIPT_VBEVALUATE"
Enabled=INTEGER|-1
Name=STRING|"VB Evaluate"
Params=FOLDER

[Actions\Action2\Params]
expression=STRING|"TimeStamp(""{tm}"")"
line00000000=STRING|"function TimeStamp(StrTime)"
line00000001=STRING|"  tim = CDate(StrTime)"
line00000002=STRING|"  h = Hour(tim)"
line00000003=STRING|"  m = Minute(tim)"
line00000004=STRING|"  s = Second(tim)"
line00000006=STRING|"  timestamp = cstr((s + m*60 + h*3600)*1000)"
line00000007=STRING|"end Function"
line00000009=STRING|"'LogMessage(TimeStamp(""22:00:01""))"
linecount=STRING|"10"
loadfromfile=STRING|"1"
variable=STRING|"stamp"

[Actions\Action3]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action3\Params]
message=STRING|"time = {tm}; TimeStamp = {stamp}"
type=STRING|"3"

Oleg Yershov
george
Posts: 25
Joined: Sun Mar 25, 2018 3:02 pm

Re: Time to timestamp

Post by george »

Perfect!

Thanks Oleg
Post Reply