2013년 10월 14일 월요일
Parsing, formatting, and manipulating dates
var date = new Date(2011, 6, 6, 22, 30);
Ext.Date.patterns = {
ISO8601Long: "Y-m-d H:i:sP",
ISO8601Short: "Y-m-d",
ShortDate: "n/j/y",
FullDateTime: "l, F d, Y g:i:s A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO"
};
// 2011-07-06 22:30:00+01:00
console.log(Ext.Date.format(date, Ext.Date.patterns.ISO8601Long));
//2011-07-06
console.log(Ext.Date.format(date, Ext.Date.patterns.
ISO8601Short));
//7/6/11
console.log(Ext.Date.format(date, Ext.Date.patterns.ShortDate));
//Wednesday, July 06, 2011 10:30:00 PM
console.log(Ext.Date.format(date, Ext.Date.patterns.
FullDateTime));
//10:30:00 PM
console.log(Ext.Date.format(date, Ext.Date.patterns.LongTime));
//2011-07-06T22:30:00
console.log(Ext.Date.format(date, Ext.Date.patterns.
SortableDateTime));
//2011-07-06 22:30:00+0100
console.log(Ext.Date.format(date, Ext.Date.patterns.
UniversalSortableDateTime));
//Wednesday, the 6th of July 2011 10:30:00 PM
console.log(Ext.Date.format(date, 'l, \\t\\he jS \\of F Y h:i:s
A'));
//Mon Mar 07 2011 00:00:00 GMT+0000 (GMT Standard Time)
console.log(Ext.Date.parse("3", 'n'));
//Mon May 17 2010 00:00:00 GMT+0100 (GMT Daylight Time)
console.log(Ext.Date.parse("2010-05-17", "Y-m-d"));
//output: null as the date is invalid
console.log(Ext.Date.parse("2011-11-31", "Y-m-d", true));
//true
console.log(Ext.Date.between(new Date('07/01/2011'), new
Date('05/01/2011'), new Date('09/01/2011')));
//Thu Sep 30 2010 00:00:00 GMT+0100 (GMT Daylight Time)
console.log(Ext.Date.add(new Date('09/30/2011'), Ext.Date.YEAR,
-1));
//Sun Jul 31 2011 00:00:00 GMT+0100 (GMT Daylight Time)
console.log(Ext.Date.getLastDateOfMonth(new Date('07/01/2011')));
// true
console.log(Ext.Date.isDST(new Date('07/01/2011')));
//false
console.log(Ext.Date.isValid(2011, 29, 2));
Ext.Date.defaultFormat = 'd/m/Y';.
ff getDayOfYear(Date date) is used for getting the numeric day of the year.
ff getDaysInMonth(Date date) is used for getting the number of days in a
given month.
ff getElapsed(Date dateA, [Date dateB]) is used for finding out the number
of milliseconds between two dates. If you don't include the dateB parameter, it will
default to the current date.
ff getGMTOffset(Date date, [Boolean colon]) is used for getting the GMT
offset of a given date (for example, +02:00). If you exclude the colon parameter
the output would be +0200.
ff getTimezone(Date date) will return the abbreviated timezone name.
피드 구독하기:
댓글 (Atom)
댓글 없음:
댓글 쓰기