You can use the date
function to get the current date and time, and then use the datestr
function to format it into the desired form:
main.m69 chars3 lines
The now
function returns the current date and time as a serial date number, which datestr
then formats into a string using the specified format. Note that I used HH
instead of hh
for the hours, as HH
gives the hours in 24-hour format whereas hh
gives the hours in 12-hour format.
This will output the current date and time in the format dd_mm_yyyy_HH_MM
(with underscores as separators between the components), e.g. 17_08_2021_17_32
.
gistlibby LogSnag