Javascript Date setTimeToNow()

Description

Javascript Date setTimeToNow()


Date.today = function() 
{
    if(this.relativeTo == null)
      return new Date().clearTime();
    else//from w  ww  . j av a  2  s .  c  o m
      return this.relativeTo.clone().clearTime();
}

Date.setRelativeTo = function(d) 
{
    this.relativeTo = d;
}

Date.prototype.setTimeToNow = function () 
{
    var n = Date.relativeTo || new Date();
    this.setHours(n.getHours());
    this.setMinutes(n.getMinutes());
    this.setSeconds(n.getSeconds());
    this.setMilliseconds(n.getMilliseconds());
    return this;
}



PreviousNext

Related