Time and time stamp conversion

Time turn timestamp: 

  var dateSel="2019-05-31 10:20"

  Date.parse (dateSel); // default here will be converted to 000 milliseconds

Timestamp transfer time:
   
myTime (nS) {// rotation time stamp

    if (nS == "" || nS == null) {

      var noday = "0";
      return noday;
    } else {
      var mydate = new Date(parseInt(nS));
      var year=mydate.getFullYear();
      var month = mydate.getMonth () + 1; // returns the month, as the return value is zero, for January, so do the processing +1
      var days = mydate.getDate();
      var hours=mydate.getHours();
      var minutes=mydate.getMinutes();
      var seconds=mydate.getSeconds();
      return year+"-"+month+"-"+days+" "+hours+":"+minutes
    }
}
  
 

Guess you like

Origin www.cnblogs.com/weijiahao/p/11824853.html