JavaScript Date Processing Library-datejs.js

Source: Internet
Author: User

Original: http://code.google.com/p/datejs/wiki/APIDocumentationjavascript Date processing Library-datejs.js
  1. Time of day

    Date.today();
  2. Compare two time sizes, return -1,0,1

    var today = Date.today (); var past = Date.today (). Add ( -6). Days (), var future = Date.today ()                    . Add (6). Days ();D Ate.compare (today, the future);    -1date.compare (Today, New Date (). Cleartime ()); 0date.compare (Today, past)  
  3. compare time within two time (closed interval)

    var past = new Date (4, 5); var future = new Date (one, one, and All) Date.today (). Between (past , future); True|false  
  4. Whether after the specified date or not before the specified date

    var tomorrow = new Date().add(1).day(); Date.today().isAfter(tomorrow); // falseDate.today().isBefore(tomorrow); // truevar yesterday = new Date().add(-1).day();Date.today().isAfter(yesterday); // trueDate.today().isBefore(yesterday); // false// No date to compare to...     Date.today().isAfter(); // falseDate.today().isBefore(); // true
  5. Get the day of the year

    Pre style= "margin-top:15px; margin-bottom:15px; PADDING:6PX 10px; border:1px solid RGB (204,204,204); font-size:13px; Font-family:consolas, ' Liberation Mono ', Courier,monospace; Background-color:rgb (248,248,248); line-height:19px; Overflow:auto ">date.today (). Getordinalnumber ()
  6. get time zone

    date.today (). getTimeZone ();  
  7. get the UTC offset for the specified time, ' + ' or '-'

    date.today (). GetUtcOffset (); " -0600"  
  8. Get week of the specified time Year (non-UTC time), here Monday is the first day of the week, not Sunday oh

    date.today (). Getweek ();  
  9. Is there daylight saving time in the current timezone

    Pre style= "margin-top:15px; margin-bottom:15px; PADDING:6PX 10px; border:1px solid RGB (204,204,204); font-size:13px; Font-family:consolas, ' Liberation Mono ', Courier,monospace; Background-color:rgb (248,248,248); line-height:19px; Overflow:auto ">date.today (). Hasdaylightsavingtime ();
  10. date.today (). IsDaylightSavingTime (); True|false  
  11. return up/next day of Week, if the day is Sunday

    date.today (). Movetodayofweek (0); Move to Next Sundaydate.today (). Movetodayofweek (0,-1); Move to last Sunday  
  12. Returns the time of the first day of the month (assuming the current date is 2007-10 -19)

    date.today (). Movetofirstdayofmonth (); 1-nov-2007  
  13. Returns the time of the last day of the month (assuming the current date is 2007-1 0-19)

    new Date (): Movetolastdayofmonth (); 30-nov-2007  
  14. Returns the time of the previous or next specified month of the specified time , 0 stands for January, 11 for December

    date.today (). Movetomonth (0); Move to Next Januarydate.today (). Movetomonth (0,-1); Move to last January  
  15. set time

    date.today (). Set ({day:15, hour:8}); Sets the day to the 15th day of the current month and the hour to 8 (AM).  
  16. Setting the time zone

    Date.today().setTimezone("PST");
  17. Formatted Date (YYYY-MM-DD HH:mm:ss)

    Date.today().toString();           // native .toString() functionalityDate.today().toString("M/d/yyyy"); // 11/19/2007Date.today().toString("d-MMM-yyyy"); // 19-Nov-2007new Date().toString("HH:mm");      // 18:45

JavaScript Date Processing Library-datejs.js

Related Article

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.