get todays date in certain format (only numbers) in matlab

You can format the current date using the datetime function and then use the datestr function to convert it to a string in the desired format. Here is an example:

main.m
formatOut = 'yyyymmdd'; % set desired format
todayDate = datetime('today'); % get current date
dateStr = datestr(todayDate,formatOut); % convert to string in desired format
disp(dateStr); % display the result
209 chars
5 lines

This will output the current date in the format yyyymmdd, which consists of the year (four digits), month (two digits) and day (two digits), all concatenated together without any separators. You can change the formatOut variable to use a different format if needed.

related categories

gistlibby LogSnag