將分鍾轉化為**小時**分鍾,,將秒轉化為**天**小時**分鍾**秒


 // 分鍾轉化成多少小時多少分鍾
      toHourMinute(minutes){
        return (Math.floor(minutes/60) + "小時" + (minutes%60) + "分" );
        // 也可以轉換為json,以方便外部使用
        // return {hour:Math.floor(minutes/60),minute:(minutes%60)};
      },
      formatSeconds(value){
        var theTime = parseInt(value);// 需要轉換的時間秒
        var theTime1 = 0; // 分
        var theTime2 = 0; // 小時
        var theTime3 = 0; // 天
        if(theTime > 60) {
          theTime1 = parseInt(theTime/60);
          theTime = parseInt(theTime%60);
          if(theTime1 > 60) {
            theTime2 = parseInt(theTime1/60);
            theTime1 = parseInt(theTime1%60);
            if(theTime2 > 24){
              //大於24小時
              theTime3 = parseInt(theTime2/24);
              theTime2 = parseInt(theTime2%24);
            }
          }
        }
        var result = '';
        if(theTime > 0){
          result = ""+parseInt(theTime)+"秒"
        }
        if(theTime1 > 0) {
          result = ""+parseInt(theTime1)+"分"+result
        }
        if(theTime2 > 0) {
          result = ""+parseInt(theTime2)+"小時"+result
        }
        if(theTime3 > 0) {
          result = ""+parseInt(theTime3)+"天"+result
        }
        return result
      },

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM