amis's notebooks

  • Untitled - /amis/amis
    Last edited a year ago
    const _ = require('lodash') const date = new Date() const DBtoday = `${date.getFullYear()}${_.padStart(date.getMonth() + 1, 2, '0')}${_.padStart(date.getDate(), 2, '0')}` const Registerdt = function(days) { const Registerdays = new Date(days * 24 * 60 * 60 * 1000) const RegisterDate = new Date(date - Registerdays) const StrDt = '' const dt = StrDt.concat(`${RegisterDate.getFullYear()}` + `-${_.padStart(RegisterDate.getMonth() + 1, 2, '0')}` + `-${_.padStart(RegisterDate.getDate(), 2, '0')}` + ` ${_.padStart(RegisterDate.getHours(), 2, '0')}` + `:${_.padStart(RegisterDate.getMinutes(), 2, '0')}` + `:${_.padStart(RegisterDate.getSeconds(), 2, '0')}`) return dt } console.log(DBtoday,date,Registerdt(0),Registerdt(30))