question

Malcolm L3 avatar image
0 Likes"
Malcolm L3 asked Jason Lightfoot edited

How do I convert 24 hours time to seconds?

Hi all,


I am able to make use of the "Advance" Mode in Date-Time schedule to implement my model to start at a particular time with it being able to reference to global table with "Number" data type. However, I face issue with converting the 24 hours time e.g (16:00:00) into my model unit time which is in seconds. Thus, I would need help in converting 16:00:00 time into seconds which is (16 x 60 x 60 + 0 x 60 + 0 ), May I know if there is any inbuilt function to convert the referenced value of 16:00:00 (I believe it's a string type) into seconds ( this is base model unit I believe).

FlexSim 20.2.0
flexsim 20.2.0software
1614173745918.png (258.9 KiB)
1614173763431.png (431.5 KiB)
· 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
0 Likes"
Jason Lightfoot answered Jason Lightfoot edited

UPDATE: this is easiest :

  1. double time = DateTime("16:00:00","%T"); //assigns the time in model time units


If you're importing from Excel you should be able to preserve the numeric value and then convert from Exceltime using the DateTime class.

You control the base model unit when you start FlexSim with the option to select units, or set the default units in Global Preferences under Environment:

You can concatenate the two strings for date and time in your model and convert to a DateTime and then get the hour using:

  1. DateTime dt=DateTime("09/02/2021 16:00:00","%d/%m/%Y %H:%M:%S");
  2. return hours(dt.hour);

But I'm not sure what you're trying to do - if you want to know how far off in the simulation a date is then just subtract one date time from the other.

  1. DateTime dt=DateTime("09/02/2021 16:00:00","%d/%m/%Y %H:%M:%S");
  2. return dt-Model.dateTime;



1614174044889.png (14.4 KiB)
· 7
5 |100000

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

Joerg Vogel avatar image
0 Likes"
Joerg Vogel answered

January 1st 1601 12:34:56 as date time will return in seconds the day time 12:34:56

Please compute the time in seconds of a date day not to the current date instead to the january 1st 1601.

There are the date time FlexSim counts in seconds January 1st, 1601; the model runtime start date in Main Menu in Model settings > it is the current date you run a model at 8 o’clock AM; the runtime in seconds from the start date time of your model by Model.time.

There are properties in Model and DateTime class, which you can use as constants to get fix time values to compute the elapsed times in seconds. The DateTime class is only a translator to visualize the time in seconds from January 1st, 1601 as strings and convert strings to seconds elapsed since January 1st, 1601.

The model run start time is only an offset to the January 1st, 1601 00:00:00.



5 |100000

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