kefu/wechathook/static/js/functions.js

11 lines
440 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function getNowDate() {
var now = new Date();
// 直接使用toLocaleString格式化日期时间并指定时区为东八区中国
var chinaTimeStr = now.toLocaleString("zh-CN", {timeZone: "Asia/Shanghai"});
// 如果需要去掉中文的日期月份,可以进一步处理
var parts = chinaTimeStr.split(" ");
var formattedDate = parts[0].replace(/\//g, "-") + " " + parts[1];
return formattedDate;
}