ExtJS Date format character code _extjs

Source: Internet
Author: User
The date class provides fewer methods in ExtJS. But on the other hand, for historical reasons, now date is a lot of letters in any language that characterize its format variables. This section focuses on date format representations of dates. These are the contents of the ExtJS API, if there is a Chinese version can jump directly over here. If you need to keep looking, note that the format characters are case-sensitive.

Years

The number of Y years indicates that 4 digits, such as 1999
Two digits of y years, for example 99 or 03
o ISO-8601 number representation (same as Y, but if the number of ISO weeks belongs to the previous year or the next year, then the year) for example 1998 or 2004
L is a leap year. 1 represents a leap year, otherwise 0

Month
The full name of the month F. Januray to December
The abbreviation for the M-month text. to Dec.
The number of M months indicates that 0 begins. For example 01 to 12
n the number of months, not beginning with 0. 1 to 12

Week
D represents the abbreviation of the weekly transit. For example, Mon to Sun
L, like D, is just a full name, like Sunday to Saturday.
W 7 days a week number for 0 (Sunday) to 6 (Saturday)
N ISO-8601 a 7-day week of digital representation. 1 expression Monday (Monday) to 7 means Sunday (Sunday)
W ISO-8601 The number of weeks in a year. Counted weekly from Monday onwards. So there are 01-53, the order is marked for 53 weeks.

Day
D, with two digits beginning with 0, represents the day of one months. For example, 01 to 31
J is the same as D, except that it doesn't start with 0. For example, 1 to 31
t the number of days in a given month. 28 to 31
S English suffix, used to indicate one months of the day, 2 characters, with J can be good match. For example, St,nd,rd, or th (1st,2nd,3rd,4th)
Z A number of 365 days a year is indicated, starting from 0. That is 0-364, leap year is 0-365.

last Afternoon
A am and PM lowercase. For example, am or PM
Uppercase for a AM and PM. For example, am or PM

when
G does not start with 0 12-hour format, 1 to 12
H 12-hour format starting with 0, 01 to 12
G does not start with 0 24-hour format, 0 to 23
H 24-hour format starting with 0, 00 to 23

points
I with 0 minutes of the opening, 00 to 59

seconds
S with 0 seconds in the beginning, 00 to 59.
The decimal part of the U-second. At least one digit, more than the limit. For example, 001 represents 0.001 seconds. 999 represents 0.999 seconds. 12312312 represents 0.12312312 seconds.
U start from the Unix era (January 1 1970 00:00:00 GMT) to the current second. For example 1193432466
Z the number of seconds in the current time zone compared to UTC, if the west side of UTC is negative, and the east is positive. -4300 to 50400

Time Zone
O and Greenwich time difference. For example +1030
The time difference between P with a colon and Greenwich time. such as -08:00
T is the abbreviation for the time zone where the current code machine is running. such as EST,MDT,PDT
C ISO8601 Date Representation (note, if the second has a decimal part, then at least 1 digits, more than unlimited.) See Www.w3.org/TR/NOTE-datetiem for 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 format character for date. In the use of the process to pay special attention, because sometimes we customize the format, we will encounter some words in the letter and format characters consistent. Of course this time we need to output a word instead of what a date represents. For this time, you must use an escape character to process. For example:

var dt = new Date (' 1/10/2007 03:05:01 PM GMT-0600 ');
document.write (Dt.format (' y-m-d ')); 2007-01-10
document.write (Dt.format (' F J, Y, g:i a ')); January, 2007, 3:05 PM
document.write (Dt.format (' L, \\t\\he jS \\of F Y h:i:s A ')); Wednesday, the 10th of January 2007 03:05:01 PM

Here is a date-style object, which is useful in the API. Although it is not a part of date itself. But the flexible application will bring great convenience to the writing of the program.
Copy Code code as follows:

Date.patterns = {
Iso8601long: "Y-m-d h:i:s",
Iso8601short: "Y-m-d",
ShortDate: "N/j/y",
Longdate: "L, F D, Y",
Fulldatetime: "L, F D, Y g:i:s A",
MonthDay: "F D",
Shorttime: "G:i A",
Longtime: "G:i:s A",
Sortabledatetime: "Y-m-d\\th:i:s",
Universalsortabledatetime: "Y-m-d h:i:so",
Yearmonth: "F, Y"
};

Case:
Copy Code code as follows:

var dt = new Date ();
document.write (Dt.format (Date.patterns.ShortDate));

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.