The $time[format] variable
One of the trickiest things to do with code is define a precise time for something to execute. When you consider that minutes are based on intervals of 60 seconds, hours on 60 minutes, days 24 hours, weeks on seven days, months on an arbitrary number of days that changes by the month and can change depending on the year and years based on a specific number of days that can also change based on the year and you can see that things can get very complicated when you look at edge cases.Fortunately Firebot has a very powerful time and date variable that, when used correctly, can save you a lot of effort trying to figure out edge cases and program for them.

Screenshot of the EXPECTED VALUE input box. Where to find it Firebot has a lot of very useful variables, you can find them by clicking on the small blue $vars button that you can see in the image above. It will show up whenever they are available, and it will show you a list of variables that you can use in that location. It will be context dependent and will only show you the variables that you can use in that location. I highly recommend spending some time looking through the variables list and the examples provided there, it can be very informative.

In the above image you can see the $vars context menu. In the search bar I’ve typed “time” and I’ve made sure I am in the “All” or “Common” tab. If you then click on “Other examples” it will also show you the $time[format] use of the variable.

Using the variable
Anywhere you see the $vars button you can type $time into the input box and it will replace $time with the current time for whoever triggered the effect containing that variable.

It will be formatted to h:m a. “h” will be the hour 1-12, “m” will be the minute 00-59 and “a” will be am/pm So if it is 9:34 in the evening it will become “9:34 pm”.

For more advanced use you can use $time[format] along with the formatting rules that you can find here: https://momentjs.com/docs/#/displaying/. You can ignore moment().format(String); and just replace “format” in the $time[format] variable with the format that you want the date and time to display.

Example usage

There are too many formats to go through them all and they are already well explained in the momentjs documentation anyway. So I will explain one of the most useful ways you can use the variable.

If you look at the momentjs documentation you can see that X will output Unix time in seconds. This is useful because Unix time is a consistently rising number.

This means if we use $time[X] we will get a constantly rising integer set in seconds.

This makes it easy to compare against, whereas a different format like $time[ssmmHHDDMMYY] may be larger or smaller depending on the time of day, the day, month etc.

If we want to (for example) set a user timeout for an effect we can set metadata as $time[X] and then use a conditional effect to check if the current time is equal to or more than the saved metadata + the length of time you want timeout the user from that effect for, in seconds.