Use the following to convert a UNIX timestamp to a human readable date and time format.
--- Retrieve the current timestamplocal timestamp = utils.dates.convert_timestamp().timestamp--- Utils objectlocal converted_date = utils.dates.convert_timestamp(timestamp).datelocal converted_time = utils.dates.convert_timestamp(timestamp).timelocal converted_formatted = utils.dates.convert_timestamp(timestamp).formatted--- Direct exportlocal converted_date = exports.boii_utils:convert_timestamp(timestamp).datelocal converted_time = exports.boii_utils:convert_timestamp(timestamp).timelocal converted_formatted = exports.boii_utils:convert_timestamp(timestamp).formatted
get_current_date_time
Use the following to retrieve the current date and time.
--- Utils objectlocal date = utils.dates.get_current_date_time().datelocal time = utils.dates.get_current_date_time().timelocal formatted = utils.dates.get_current_date_time().formatted --- Direct exportlocal date = exports.boii_utils:get_current_date_time().datelocal time = exports.boii_utils:get_current_date_time().timelocal formatted = exports.boii_utils:get_current_date_time().formatted
add_days_to_date
Use the following to add a number of days to a given date.
--- Retrieve datelocal date = utils.dates.get_current_date_time().date--- Specify days to addlocal days =3--- Utils objectlocal new_date = utils.dates.add_days_to_date(date, days)--- Direct exportlocal new_date = exports.boii_utils:add_days_to_date(date, days)
date_difference
Use the following to calculate the difference between two dates.
--- Retrieve datelocal date = utils.dates.get_current_date_time().date--- Specify days to addlocal days =3--- Specify new date *using add_days_to_date for example*local new_date = utils.dates.add_days_to_date(date, days)--- Utils objectlocal date_difference = utils.dates.date_difference(date, new_date)print('Date Difference:', date_difference')--- Direct exportlocal date_difference = exports.boii_utils:date_difference(date, new_date)
convert_timestamp_ms
Use the following to convert a UNIX timestamp in milliseconds to a human readable date-time format.
--- Specify/retrieve timestamplocal timestamp =1628759592000--- Utils objectlocal date = utils.dates.convert_timestamp_ms(timestamp).datelocal time = utils.dates.convert_timestamp_ms(timestamp).timelocal formatted = utils.dates.convert_timestamp_ms(timestamp).formatted--- Direct exportlocal date = exports.boii_utils:convert_timestamp_ms(timestamp).datelocal time = exports.boii_utils:convert_timestamp_ms(timestamp).timelocal formatted = exports.boii_utils:convert_timestamp_ms(timestamp).formatted
timestamp_difference_ms
Use the following to calculate the difference between two timestamps.