Nodejs Utililty Methods Time Convert

List of utility methods to do Time Convert

Description

The list of methods to do Time Convert are organized into topic(s).

Method

changeToSeconds()
Number.prototype.changeToSeconds=function(){
    var ms=this;
    his=ms.getHisByMs();
    var h=parseInt(his[0])*60*60;
    var m=parseInt(his[1])*60;
    var s=parseInt(his[2]);
    var second=h+m+s;
    return second;
day()
Number.prototype.day = Number.prototype.days = function() {
  return (this * 3600 * 24 * 1000);
};
days()
Number.prototype.days = function () {
  var i = this.valueOf();
  var t = new Date(1000 * 60 * 60 * 24 * i);
  return new Date(t).getTime();
};
days_after(cb)
Number.prototype.days_after = function(cb){
  setTimeout(cb, this*1000);
};
var i=5;
i.days_after(function(){
  console.log('test');
});
getWeek()
Number.prototype.getWeek=function(){
    var weekDayList=["?","?","?","?","?","?","?"] ;
    var date=new Date(this.dateFormat());
    var weekDay=weekDayList[date.getDay()];
    return weekDay;
getWeekDayFromNow(num)
Number.prototype.getWeekDayFromNow=function(num){
    var date=this;
    var ymd=[];
    var res=[];
    ymd.push(date.getFullYear());
    ymd.push(Number(date.getMonth()+1).addZero());
    ymd.push(Number(date.getDate()).addZero());
    var origin=Number(ymd.join(""));
    res.push(origin+"");
...
minute()
Number.prototype.minute = Number.prototype.minutes = function() {
  return (this * 60 * 1000);
};
minutes()
Number.prototype.minutes = function () {
  var i = this.valueOf();
  var t = new Date(1000 * 60 * i);
  return new Date(t).getTime();
};
months()
Number.prototype.months = function () {
  var i = this.valueOf();
  var t = new Date(1000 * 60 * 60 * 24 * 30 * i);
  return new Date(t).getTime();
};
second()
Number.prototype.second = function() {
  return this;
};
Number.prototype.seconds = function() {
  return this.second();
};
Number.prototype.minute = function() {
  return this.seconds() * 60;
};
...