Matlab: date and time

Using now or now() command in Matlab can return current date and time as a serial date number. It is counting how many days has passed A.D.

>> now
ans =
7.3449e+05

Remember there are 365.2422 days in a year.

In case of generating a string, use

>> datestr(now,30)
ans =
20101214T122614
>> datestr(now,31)
ans =
2010-12-14 12:26:22

Format 30 can be used in file names, while format 31 can be used in dates inserted in text. Or you can define your own format:

>> datestr(now,'mmddyyyy')
ans =
12142010

Advertisements
Matlab: date and time

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s