
Extends the Date Type to include more powerful parsing and formatting functions; this is a further extention and depends on Date.js.
MIT-style license
In addition to the two default parsers included in Date.js, Date.Extras.js includes some additional parsers.
Date.parse('today') //"Mon Dec 10 2007 00:00:00 GMT-0800 (Pacific Standard Time)" Date.parse('tomorrow') //"Tue Dec 11 2007 00:00:00 GMT-0800 (Pacific Standard Time)" Date.parse('yesterday') //"Sun Dec 09 2007 00:00:00 GMT-0800 (Pacific Standard Time)" Date.parse('next monday') //"Mon Dec 17 2007 00:00:00 GMT-0800 (Pacific Standard Time)" Date.parse('last wednesday') //"Wed Dec 05 2007 00:00:00 GMT-0800 (Pacific Standard Time)"
Returns the difference between two dates in a compact format.
date.timeDiff([to, separator]);
var example = new Date(); example.timeDiff(); //0s example.decrement('minute'); example.timeDiff(); //1m:0s example.decrement('hour'); example.timeDiff(); //1h:1m:0s example.increment('hour', 2); example.timeDiff(); //3h:1m:0s
date.timeDiffInWords([to]);
var example = new Date(); example.timeDiffInWords(); //less than a minute ago example.decrement('hour'); example.timeDiffInWords(); //about an hour ago example.increment('hour', 2); example.timeDiffInWords(); //about an hour from now
This method is now an alias for the old Date.timeAgoInWords.
© Linux.ria.ua, 2008-2024 |