Original: http://code.google.com/p/datejs/wiki/APIDocumentationjavascript Date processing Library-datejs.js
Time of day
Date.today();
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)
-
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
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
-
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 ()
-
get time zone
date.today (). getTimeZone ();
-
get the UTC offset for the specified time, ' + ' or '-'
date.today (). GetUtcOffset (); " -0600"
-
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 ();
-
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 ();
-
date.today (). IsDaylightSavingTime (); True|false
-
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
-
Returns the time of the first day of the month (assuming the current date is 2007-10 -19)
date.today (). Movetofirstdayofmonth (); 1-nov-2007
-
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
-
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
-
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).
Setting the time zone
Date.today().setTimezone("PST");
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