The Date in ExtJs is basically a subset of the PHPdate function, which represents a Date object. So far. There are few methods provided by the Date class in ExtJs. However, on the other hand, due to historical reasons, there are many letters describing the format variables of Date in any language. This section describes the Date format representation. These are all content in ExtJs API. If you have a Chinese version, you can skip this step. If you want to continue reading, note that the characters in the format are uppercase and lowercase sensitive.
Year
The number of Y years. Four digits, for example, 1999
Double-digit expression of year y, for example, 99 or 03
O iso-october number (the same as Y, but if the number of ISO weeks belongs to the previous year or the next year, that year will be used) for example 1998 or 2004
L whether it is a leap year. 1 indicates a leap year, otherwise 0
Month
The full name of month F. Januray to December
Abbreviated M month text. Jan to Dec
The number of the Month of m, starting from 0. For example, 01 to 12
The number of n months, not starting with 0. 1 to 12
Week
D indicates the abbreviation of the day of the week. For example, Mon to Sun
L like D, it is just the full name, such as Sunday to Saturday
W the number of 7 days in a week indicates 0 (Sunday) to 6 (Saturday)
N ISO-8601 represents a number of seven days a week. 1 indicates Monday to 7 indicates Sunday)
W ISO-8601 the number of weeks in a year. It starts from Monday every week. So 01-53 marked 53 weeks in sequence.
Day
The double digits that start with 0 represent the day of a month. For example, 01 to 31
The content of j is the same as that of d, except that it does not start with 0. For example, 1 to 31
T indicates the number of days in a given month. 28 to 31
The suffix described in S English is used to indicate a period of time in a month. It can be 2 characters in length and can work well with j. For example, st, nd, rd, or th (1st, 2nd, 3rd, 4th)
Z indicates the number of 365 days a year, starting from 0. 0-364, and leap year is 0-365
Last afternoon
Lowercase letters of a AM and PM. For example, am or pm
Uppercase letters of a am and PM. For example, AM or PM
Hour
G does not start with 0 in the 12-hour format, 1 to 12
The format of h starting with 0 in 12 hours, 01 to 12
G is not in the 24-hour format starting with 0, 0 to 23
The 24-hour format starting with 0 for H, ranging from 00 to 23.
Minute
I start with 0 minutes, 00 to 59
Seconds
Seconds starting with 0, 00 to 59
The fractional part of the u second. It must be at least one digit without limitation. For example, 001 indicates 0.001 seconds. 999 indicates 0.999 seconds. 12312312 indicates 0.12312312 seconds.
U starts from the Unix epoch (January 1 1970 00:00:00 GMT) to the current second. For example, 1193432466
The number of seconds in which the current time zone of Z differs from UTC. If it is in the west of UTC, It is a negative number and the East is a positive number. -4300 to 50400
Time Zone
O and Greenwich Mean Time Difference. Example: + 1030
The time difference between the colon and Greenwich Mean Time of P. For example
T stands for the time zone in which the current code machine runs. For example, EST, MDT, and PDT
C ISO8601 date representation (Note: if there is a decimal part in the second, it should be at least one digit, not limited. See www.w3.org/tr/note-datetiemto get more content. Example: 2007-04-17T15: 19: 21 + 08: 00 or 2008-03-16T16: 18: 22Z or 2009-02-15T17: 17: 23.9 + 01: 00 or 2010-01-14T18: 16: 24, 999876543-07:00
The above is the Date format. Pay special attention to the usage process, because sometimes when we customize the format, we may encounter situations where the letters in some words are consistent with the format characters. Of course, at this time, we need to output words instead of the content represented by a Date. In this case, escape characters must be used for processing. For example:
Var dt = new Date ('2017/1/10 03:05:01 GMT-0600 ');
Document. write (dt. format ('Y-m-d'); // 2007-01-10
Document. write (dt. format ('f j, Y, g: I A'); // January 10,200 7
Document. write (dt. format ('l, \ t \ he jS \ of f y h: I: s A'); // Wednesday, the 10th of January 2007 03:05:01
The following is a date style object, which is useful in the API. Although it is not part of Date itself. However, flexible application will bring great convenience to program writing.
The Code is as follows:
Date. patterns = {
ISO8601Long: "Y-m-d H: I: s ",
ISO8601Short: "Y-m-d ",
Expiry date: "n/j/Y ",
LongDate: "l, F d, Y ",
FullDateTime: "l, F d, Y g: I: s ",
MonthDay: "F d ",
Processing time: "g: I ",
LongTime: "g: I: s ",
SortableDateTime: "Y-m-d \ TH: I: s ",
UniversalSortableDateTime: "Y-m-d H: I: sO ",
YearMonth: "F, Y"
};
Use Case:
The Code is as follows:
Var dt = new Date ();
Document. write (dt. format (Date. patterns. interval Date ));