Here you can find the source of timeToMidnight()
/**/*from ww w .ja va 2s. c om*/ * Sets the time of the date of the Date object to midnight 0:00 hours */ Date.prototype.timeToMidnight = function() { this.setHours(0); this.setMinutes(0); this.setMilliseconds(0); };
var timeFmt = function (aDate) { if (null == aDate) { return ""; else { return new Date(aDate).format("yyyy-MM-dd hh:mm:ss"); };
Date.prototype.timeSecond = function () { return ((this.getSeconds() < 10)?"0":"") + this.getSeconds();
String.prototype.startsWith = function (str){ return this.indexOf(str) === 0; }; timeSince = function (date) { var seconds = Math.floor((new Date() - date) / 1000); var interval = Math.floor(seconds / 31536000); if (interval >= 1) { if(interval == 1){ return "about " + interval + " year ago"; ...
var DAY_WIDTH = 100; var DAY_HEIGHT = 80; var SIDE_DELTA = 2; var DAY_HEADING = ["SUN", "MON", "TUE", "WED", "THU", "FRI", ...
Date.prototype.timeToJSON = function() { return this.toLocaleTimeString().substring(0,5); };
function time_between_in_words(from_date, to_date) return format_milliseconds(Math.abs(from_date.getTime()-to_date.getTime())); function time_ago_in_words(date) return format_milliseconds(Math.abs(Date.now()-date.getTime())); function format_milliseconds(milsecs) ...
var chunks = [ [60 * 60 * 24 * 365, 'year'], [60 * 60 * 24 * 30, 'month'], [60 * 60 * 24 * 7, 'week'], [60 * 60 * 24, 'day'], [60 * 60, 'hour'], [60, 'minute'] ]; Date.prototype.time_since = function() { ...
Date.prototype.timesince = function(now) { var chunks = [ [ 60 * 60 * 24 * 365, 'year', 'years'], [ 60 * 60 * 24 * 30, 'month', 'months' ], [ 60 * 60 * 24, 'day', 'days' ], [ 60 * 60, 'hour', 'hours' ], [ 60, 'minute', 'minutes' ] ]; now = now || new Date(); ...
Date.prototype.withoutTime = function () { var d = new Date(this); d.setHours(0, 0, 0, 0); return d;