ExtJS Use of date

Source: Internet
Author: User

Reproduced!!!

Ext.date is a singleton class that encapsulates a series of date manipulation functions, extending the functionality of JavaScript date, with some common features listed below.

Ext.Date.add (date, interval, value) increases or decreases the time for date, which does not change the value of the original Date object, but instead returns a new Date object.

Ext.Date.between (date, start, end) determines whether the date is between start and end.

Ext.Date.clearTime (date, clone) sets the time of date to 00 hours, 00 minutes, 00 seconds, 000 milliseconds.

Ext.Date.clone (date) clones a copy of the date.

Ext.Date.format (date, format) formats the date and returns the formatted string.

Ext.Date.getDayOfYear (date) Gets the date that is the day ordinal of the year.

Ext.Date.getDaysInMonth (date) Gets the date that is the day ordinal of the month.

Ext.Date.getFirstDateOfMonth (date) Gets the first day of the month in which the date is.

Ext.Date.getFirstDayOfMonth (date) Gets the week of the first day of the month in which the date is.

Ext.Date.getLastDateOfMonth (date) Gets the last day of the month in which date is located.

Ext.Date.getLastDayOfMonth (date) Gets the week of the last day of the month in which the date is.

Ext.Date.getWeekOfYear (date) Gets the number of weeks in the year in which the date is.

Ext.Date.isLeapYear (date) the year in which the date is in leap years.

Ext.Date.now () returns the number of milliseconds for the current time to January 1, 1970. There are already date.now () implementations of the same functionality in Chrome, IE9, and Ie10.

Ext.Date.parse (input, format, strict) creates a date based on the input string, and Date.parse () has a similar function.

Ext.Date.add (date, interval, value) increases or decreases the time for date, which does not change the value of the original Date object, but instead returns a new Date object. @param {Date} Date object.                              @param {String} interval the unit of value, you can choose Ext.Date.DAY, Ext.Date.HOUR, Ext.Date.MINUTE, Ext.Date.MONTH,// Ext.Date.SECOND, Ext.Date.YEAR, Ext.Date.MILLI. @param {Number} Value Date object requires an increased value. @return {Date} returns the Date object after the value has been incremented. Examplevar date = Ext.Date.add (new date (' 10/29/2006 '), Ext.Data.DAY, 5); Added 5 days console.log (date); Results returned Fri 2006 00:00:00 gmt+0800 (China Standard Time) var date = Ext.Date.add (new date (' 10/29/2006 '), Ext.Data.DAY,-5); Decrease by 5 days if the value is negative. Console.log (date); Returns the result Tue Oct 2006 00:00:00 gmt+0800 (China Standard Time) var date = Ext.Date.add (new date (' 10/29/2006 '), ext.data.year,2); Increased by 2 years Console.log (date); Results Wed Oct 00:00:00 gmt+0800 (Chinese Standard Time)//Ext.Date.between (date, start, end) determines whether the date is between start and end. The date to determine @param {date} date. @param {Date} start//@param {date} end//@return {BOolean} returns False if date returns true between start and end. Examplevar date = new Date (' 10/29/2006 '), var start = new Date (' 10/5/2006 '), var end = new Date (' 11/15/2006 '); Ext.Date.between (Date, start, end); return true//Ext.Date.clearTime (date, clone) to set the time of date to 00 hours, 00 minutes, 00 seconds, 000 milliseconds. @param {Date} date//@param {Bollean} clone optional parameter. If True returns a copy of date, or false to return the date itself, false by default. @return {Date} returns the date after the setting. Examplevar date = new Date (' 10/30/2012 14:30:00 ');  Ext.Date.clearTime (Date); return Tue Oct 00:00:00 gmt+0800 (China Standard Time)//Ext.Date.clone (date) clone a copy of date. @param {Date} date//@return {date} returns the cloned date. Examplevar orig = new Date (' 10/30/2012 '); var copy = Ext.Date.clone (orig); Clones a value//Ext.Date.format (date, format) to format the date, returning the formatted string. @param the {date} date. @param {string} format date format, y-year, M-month, D-Day, H-24 hour, I-minute, S-second//@return {string} returns the formatted string. Examplevar date = new Date (' 10/20/2012 14:30:00 '); Ext.Date.format (Date, ' y-m-d h:i:s ');       2012-10-20 14:30:00ext.date.format (date, ' Y year M-month D-day h:i:s '); October 20, 2012 14:30:00//Ext.Date.getDayOfYear (date) Gets date is the day of the year//@param {date} date. @return {Number} returns days, the range of values 0~364, and 365 if it is a leap year. Examplevar date = new Date (' 10/20/2012 14:30:00 '); Ext.Date.getDayOfYear (Date); Returns 293//Ext.Date.getDaysInMonth (date) Gets date is the day of the month//@param {date} date. @return {Number} returns days. Examplevar date = new Date (' 10/20/2012 14:30:00 '); Ext.Date.getDayOfYear (Date); Returns 31//Ext.Date.getFirstDateOfMonth (date) Gets the first day of the month in which the date is located//@param {date} date. @return {Date} returns the first day of the month in which it is located. Examplevar date = new Date (' 10/20/2012 14:30:00 '); Ext.Date.getFirstDateOfMonth (Date);    Back to Mon Oct 00:00:00 gmt+0800 (China Standard Time)//Ext.Date.getFirstDayOfMonth (date) Gets the day of the month in which the date is in the Week//@param {date} Date Day. @return {Number} returns the week of the first day of the month in which the value range 0~6. Examplevar date = new Date (' 10/20/2012 14:30:00 '); Ext.Date.getFirstDayOfMonth (Date); Returns 1, indicatingMonday//Ext.Date.getLastDateOfMonth (date) Gets the last day of the month in which date//@param {date} date. @return {Date} returns the last day of the month in which it was located. Examplevar date = new Date (' 10/20/2012 14:30:00 '); Ext.Date.getLastDateOfMonth (Date);    Back to Wed Oct 00:00:00 gmt+0800 (China Standard Time)//Ext.Date.getLastDayOfMonth (date) Gets the day of the month on which the date was last//@param {date} Date Day. @return {Number} returns the week of the last day of the month in which the value range 0~6. Examplevar date = new Date (' 10/20/2012 14:30:00 '); Ext.Date.getLastDayOfMonth (Date); Returns 3, which represents Wednesday//Ext.Date.getWeekOfYear (date) Gets the day of the Week//@param {date} date in the year in which the date was dated. @return {Number} returns the week ordinal of the year in which the value range is 1~53. Examplevar date = new Date (' 10/20/2012 14:30:00 '); Ext.Date.getWeekOfYear (Date); Returns whether the year of 42//Ext.Date.isLeapYear (date) date is in leap years//@param {date} date. @return {Boolean} True indicates a leap year, false indicates common year. Examplevar date = new Date (' 10/20/2012 14:30:00 '); Ext.Date.isLeapYear (Date); Returns true//Ext.Date.now () returns the number of milliseconds for the current time to January 1, 1970. In Chrome, IE9, andIe10 already has date.now () to implement the same functionality. @return {Number} returns the milliseconds.  Examplevar timestamp = Ext.Date.now ();  1351666679575var date = new Date (timestamp); Wed Oct 14:57:59 gmt+0800 (China Standard Time)//Ext.Date.parse (input, format, strict) based on the input string creation date, Date.parse () has similar functionality. @param {string} input date string. @param {String} format date. @param {Boolean} strict validates the validity of the input string, which is false by default. @param {Date} returns the date created.  Examplevar input = ' October 31, 2012 14:30:00 '; var format = ' Y year M month D Day H:i:s '; var date = Ext.Date.parse (input, format, true); Wed Oct 14:30:00 gmt+0800 (China Standard Time)

  

ExtJS Use of date

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.