date and time information matlab
2012-02-07 18:04
399 查看
Date and Time Functions
This table shows what information is available in MATLAB withrespect to dates and times and which function provides this information.The sections that follow the table provide more information on howto use the different date and time formats.Date and Time Information | Output Format | Function toUse |
---|---|---|
Current date and time | Date number | now |
Date vector | clock | |
Date string | datestr(now) | |
Current date | Date number | datenum(date) |
Date vector | datevec(date) | |
Date string | date | |
Day of week for given date | Full day name, abbreviated name, or day number in week (1-7) | weekday |
Last day of given month(s) | Vector of one or more days | eomday |
Date with modified field | Date number | addtodate |
Calendar for given month | 6-by-7 matrix of days | calendar |
Date String Tables
Symbolic Identifiers for Individual Fields
The following table shows:The nine fields of a date string (left column)
Ways to format each field
Example output for each field
Assigned character-based field identifiers
Field | StringFormat | Example of Output | Field Identifier |
---|---|---|---|
Quarter year | Letter Q and 1 digit | Q4 | 'QQ' |
Year | 4 digits | 2007 | 'yyyy' |
2 digits | 07 | 'yy' | |
Month | Full name | December | 'mmmm' |
First 3 letters | Dec | 'mmm' | |
2 digits | 12 | 'mm' | |
First letter | D | 'm' | |
Day | Full name | Tuesday | 'dddd' |
First 3 letters | Tue | 'ddd' | |
2 digits | 20 | 'dd' | |
First letter | T | 'd' | |
Hour | 2 digits | 16 | 'HH' |
Minute | 2 digits | 02 | 'MM' |
Second | 2 digits | 54 | 'SS' |
Millisecond | Decimal point and 3 digits | .057 | 'FFF' |
12-hour period | AM or PM | PM | 'AM' or 'PM' |
MATLAB interpretsthe field specifiers in this table according to your computer's languagesetting and the current MATLAB language setting.
In a field specifier string, you cannot specify any field morethan once. For example, you cannot use
'yy-mmm-dd-m' becauseit has two month identifiers. The one exception to this is that youcan combine one instance of
dd with one instanceof any of the other day identifiers:
ds = datestr(now, 'dddd mmm dd yyyy') ds = Wednesday Jun 30 2010
You only can use QQ (quarter of the year)alone or with a year specifier.
Numeric Identifiers for Predefined Formats
The following table shows numeric identifiers you can use toinclude certain field and format combinations in a date string.Date String Formats | Example of Output | Identifier to Use |
---|---|---|
'dd-mmm-yyyy HH:MM:SS' | 01-Mar-2000 15:45:17 | 0 |
'dd-mmm-yyyy' | 01-Mar-2000 | 1 |
'mm/dd/yy' | 03/01/00 | 2 |
'mmm' | Mar | 3 |
'm' | M | 4 |
'mm' | 03 | 5 |
'mm/dd' | 03/01 | 6 |
'dd' | 01 | 7 |
'ddd' | Wed | 8 |
'd' | W | 9 |
'yyyy' | 2000 | 10 |
'yy' | 00 | 11 |
'mmmyy' | Mar00 | 12 |
'HH:MM:SS' | 15:45:17 | 13 |
'HH:MM:SS PM' | 3:45:17 PM | 14 |
'HH:MM' | 15:45 | 15 |
'HH:MM PM' | 3:45 PM | 16 |
'QQ-YY' | Q1-01 | 17 |
'QQ' | Q1 | 18 |
'dd/mm' | 01/03 | 19 |
'dd/mm/yy' | 01/03/00 | 20 |
'mmm.dd,yyyy HH:MM:SS' | Mar.01,2000 15:45:17 | 21 |
'mmm.dd,yyyy' | Mar.01,2000 | 22 |
'mm/dd/yyyy' | 03/01/2000 | 23 |
'dd/mm/yyyy' | 01/03/2000 | 24 |
'yy/mm/dd' | 00/03/01 | 25 |
'yyyy/mm/dd' | 2000/03/01 | 26 |
'QQ-YYYY' | Q1-2001 | 27 |
'mmmyyyy' | Mar2000 | 28 |
'yyyy-mm-dd' (ISO 8601) | 2000-03-01 | 29 |
'yyyymmddTHHMMSS' (ISO 8601) | 20000301T154517 | 30 |
'yyyy-mm-dd HH:MM:SS' | 2000-03-01 15:45:17 | 31 |
相关文章推荐
- [Linux]Date and Time Commands
- Is not a valid date and time 不是有效的日期格式
- 解决PLSQL提示 is not a valid date and time
- Windows Phone 7 - DatePicker and TimePicker【转】
- java.util.Date vs java.sql.Date, java.sql.Time and java.sql.Timestamp
- XSD Date and Time Data Types
- mysql 12.7 Date and Time Functions
- fortran_date_and_time:获取日期和时间
- 【Js Plugin】6 Bootstrap date and time pickers
- 日期 bootsrtap-datatimepicker and bootstrap-datepicker 控件支持中文
- C Standard Library: 10 Date and Time Functions: <time.h>
- 8.1. datetime — Basic date and time types — Python v2.7.3 documentation
- VBScript: Date and Time Constants
- Get current time and date on Android
- JavaSE8-The New Date and Time API(1)
- DateAndTime 的命名空间Microsoft.VisualBasic(C#)
- 使用ole中的Microsoft Date and time picker control来添加日期选择框
- Insert Date and Time into Access
- Matlab Example-Time,Date,Week
- Date and Time Arithmetic in JScript zz