js获取周几、获取前多少个小时

       getWeekDay(date) {
                let weekArray = new Array("日", "一", "二", "三", "四", "五", "六");
                let week = weekArray[new Date(date).getDay()];//注意此处必须是先new一个Date
                return week;
            },
            timestampToTime(timestamp) {
                let date = new Date(timestamp);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
                let Y = date.getFullYear() + '-';
                let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                let D = date.getDate() + ' ';
                let h = date.getHours() + ':';
                let m = date.getMinutes() + ':';
                let s = date.getSeconds();
                return Y + M + D + h + m + s;
            },

 

上一篇:c/c++ 在main之前运行函数,在main结束后运行的函数


下一篇:号外号外!解决github+hexo+yilia评论插件的问题!!!