question

Preet avatar image
0 Likes"
Preet asked Jason Lightfoot commented

Current UTC timestamp

Is there any way in flexsim to get current UTC timestamp in the format of DD/MM/YYYY HH:MM:SS timeformat?

FlexSim 23.2.2
utc timestamp
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jason Lightfoot avatar image Jason Lightfoot ♦♦ commented ·

Hi @Preet, was one of Jason Lightfoot's or Ben Wilson's answers helpful? If so, please click the "Accept" button at the bottom of the one that best answers your question. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always comment back to reopen your question.

0 Likes 0 ·
Jason Lightfoot avatar image
0 Likes"
Jason Lightfoot answered Jason Lightfoot edited

Here's a realtime conversion script:

string yearstring=realtime(12);
yearstring=yearstring.substr(yearstring.length-4,4);
string timestring=realtime(10);
string datestring=realtime(11);
datestring=datestring.substr(1,datestring.length-2)+yearstring;
DateTime now=DateTime(datestring+" "+timestring,"%m/%d/%Y %T");
string offset=now.toString("%z");
int hrOffset=offset.substr(2,2).toNum();
int minOffset=offset.substr(4,2).toNum();
int sign=offset.substr(1,1)=="-"?-1:1;
DateTime diff=DateTime(3600*hrOffset+60*minOffset);
now=now-sign*diff;
return now.toString();


5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Ben Wilson avatar image
0 Likes"
Ben Wilson answered Preet commented

You might try the realtime() command.

realtime() returns the real clock time in a variety of formats based on the input parameter.

https://docs.flexsim.com/Reference/CodingInFlexSim/CommandReference/Commands.html#realtime

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Preet avatar image Preet commented ·
Thanks Ben! I checked it but the realtime option gives laptop time. Not UTC time.
0 Likes 0 ·