how to set the model's clock to the computer's ?

how to set the model's clock to the computer's ?

gabriel_d16
Not applicable
87 Views
3 Replies
Message 1 of 4

how to set the model's clock to the computer's ?

gabriel_d16
Not applicable

[ FlexSim 22.0.3 ]

Hello, I would like to be able to set the time of my simulation with the exact time of the PC when I launch the simulation. (with the code in Model Triggers, onRunStart)


For the moment I use this code but I don't know how to configure with the PC time :

DateTime startTime = DateTime("05/11/2022 10:27:42 AM", "%m/%d/%Y %I:%M:%S %p"); 
function_s(getmodelunit(START_TIME_NODE), "setDateTime", startTime);


Thank you for the help !

0 Likes
Accepted solutions (1)
88 Views
3 Replies
Replies (3)
Message 2 of 4

jason_lightfootVL7B4
Autodesk
Autodesk
Accepted solution

There's a post for that here. You can find the computer time with:

realtime(11)+" "+realtime(10)      // returns 05/13/22 18:04:49

or

realtime(12)       //returns   Fri May 13 18:05:54 2022


Message 3 of 4

Matthew_Gillespie
Autodesk
Autodesk

And to convert it into a DateTime:

DateTime startTime = DateTime(realtime(11) + " " + realtime(10), "%m/%d/%y %H:%M:%S");


Matthew Gillespie
FlexSim Software Developer

Message 4 of 4

gabriel_d16
Not applicable
thank you very much, it works well !
0 Likes