获取年月日时分秒

1. 获取当前年月日时分秒:

  const now = new Date(+new Date() + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/,
    '');

2. 获取半年前年月日时分秒

const dt = new Date();

dt.setMonth(dt.getMonth() - 6);

 const before = new Date(+new Date(dt) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(
    /\.[\d]{3}Z/, '');


版权声明:本文为lml_little原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。