How do I obtain current date. Is realtime() the best way to do it?
How do I obtain current date. Is realtime() the best way to do it?
There's a new command in FlexSim 2106 called convert(). Convert allows you to convert dates and times from different formats like Excel Date Time, FlexSim Date Time and Model Time. This is especially useful when importing data from Excel that is based upon specific dates and times.
A couple of ways you can use the convert() command is in conjunction with the time() command and getmodelunit()
getmodelunit(CURRENT_TIME) //Returns FS_DATETIME time() //Returns model time convert(time(), MODEL_TIME, DATETIME_STR) //Will print out date time based upon the date/time format string, for example 8:00:00 AM Fri 24 Jun 2016
Check out the command documentation for convert() for more information.
realtime() will give you the real current date and time, from your computer's clock. This should closely match the time you see on your watch, your cell phone, or the clock on the wall. This is different than the time in your simulation.
If you are looking for the current date in your simulation, this is based on your chosen time unit and start date, both specified when starting a new model.
As you're running your simulation, you can obtain various date and time values for current simulation time from the tree as shown here:
Hi @Ben Wilson ! How would I convert realtime(); to DD/MM/YYYY HH:MM:SS timeformat?
Here's a script to print your string to the output console:
string year=realtime(12).substr(21,4); // 2023 string datestr=realtime(11); // 11/13/23 string date=datestr.substr(1,6)+year; // 11/13/2023 string realtimeString=date+" "+realtime(10); // 11/13/2023 23:23:10 DateTime dt=DateTime(realtimeString,"%m/%d/%Y %T"); print (dt.toString("%d/%m/%Y %T")); // 13/11/2023 23:23:10
9 People are following this question.
FlexSim can help you understand and improve any system or process. Transform your existing data into accurate predictions.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © Autodesk Inc. All rights reserved