//毫秒转换成时间格式方法
function timestampToTime(timestamp) {
var date = new Date(timestamp);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
Y = date.getFullYear() + '-';
M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
D = date.getDate() + ' ';
h = date.getHours() + ':';
m = date.getMinutes() + ':';
s = date.getSeconds();
return Y+M+D+h+m+s;
}
Date.prototype.Format = function (fmt) {
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate()-1, //日
"h+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}
var signTime = new Date().Format("yyyy年MM月dd日"); //时间格式的转换
var wm_txt1 = $("#salesNoId").val().trim(); //水印显示的内容 给表格添加水印
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(0,0,0,0.1)';
ctx.clearRect(0, 0, 100, 100);
ctx.font = '20px Arial';
ctx.translate(30, 100);
ctx.rotate(-45 * Math.PI / 180);
ctx.fillText(wm_txt1, 0, 18);
var imgdata = canvas.toDataURL();
var tbccChild = document.getElementById("index_table"); //表格的id
tbccChild.style.backgroundImage = 'url(' + imgdata + ')';
//获取当前时间的前一天,后一天
let curDate = new Date();
let preDate = new Date(curDate.getTime() - 24*60*60*1000);