js -- 时间



1.时间格式的转换,秒化成 hour minutes seconds

changeTime:function(seconds){

        var hour=Math.floor(seconds/3600);

        var minute=Math.floor((seconds%3600)/60);

        var second=(seconds%60);


        if(parseInt(hour) < 10) hour = "0" + hour;

        if(parseInt(minute) < 10) minute = "0" + minute;

        if(parseInt(second) < 10) second = "0" + second;

        var time = hour+":"+minute+":"+second;


        return time;

    }


2.时间

var date = new Date();

date.getFullYear()

date.getMonth()

date.getHours()

(date.getMonth() + 1)).replace(/\b(\d)\b/g, "0$1")  9 --> 09










你可能感兴趣的:(js -- 时间)