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 =

Remember there are 365.2422 days in a year.

In case of generating a string, use

>> datestr(now,30)
ans =
>> 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 =

Matlab: date and time

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s