const now = new Date();
const options = { timeZone: 'Asia/Shanghai' };
const year = now.toLocaleString('zh-CN', { ...options, year: 'numeric' });
const month = now.toLocaleString('zh-CN', { ...options, month: '2-digit' });
const date = now.toLocaleString('zh-CN', { ...options, day: '2-digit' });
console.log(`${year}-${month}-${date}`);
const now = new Date();
const options = { timeZone: 'Asia/Shanghai', year: 'numeric', month: '2-digit', day: '2-digit' };
const formattedDate = now.toLocaleString('zh-CN', options);
console.log(formattedDate); // 输出格式化后的日期,例如:2024-01-26