how to get certain format of date in matlab in matlab

Matlab has the in-built function datestr() which can be used to get the desired format of date.

Here is an example to get the date in the format of yyyy-mm-dd:

main.m
formatOut = 'yyyy-mm-dd';
dateString = datestr(now,formatOut)
62 chars
3 lines

This code will return a string of the current date in the format yyyy-mm-dd.

You can modify the formatOut variable to get the date in a different format as per the requirement.

Note: The now function returns the current date and time. You can replace this with any date value for which you want to get the formatted date.

related categories

gistlibby LogSnag