
/* 日期转时间戳 */
function timeToUnix(stringTime) {
    if (stringTime) {
        var timestamp = Date.parse(new Date(stringTime));
    } else {
        var timestamp = Date.parse(new Date());
    }
    timestamp = timestamp / 1000;
    return timestamp;
}
/* 倒计时：时+分+秒 */
function changeTimeStamp(timeStamp, hasTimeRemaining) {
    var distancetime;
    if (hasTimeRemaining) {
        distancetime = timeStamp;
    } else {
        var curTimeStamp = timeToUnix();
        distancetime = parseInt(timeStamp) - curTimeStamp;
    }


    if (distancetime > 0) {
        //如果大于0.说明尚未到达截止时间       
        var day = Math.floor(distancetime / (60 * 60 * 24));
        var hour = Math.floor(distancetime / (60 * 60)) - (day * 24);
        var minute = Math.floor(distancetime / 60) - (day * 24 * 60) - (hour * 60);
        var second = Math.floor(distancetime) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);

        hour = parseInt(hour) + parseInt(day) * 24;
        if (hour < 10) {
            hour = "0" + hour;
        }
        if (minute < 10) {
            minute = "0" + minute;
        }
        if (second < 10) {
            second = "0" + second;
        }

        return [hour, minute, second];
    } else {
        return false
    }
}