diff --git a/helpers/paramconverter.js b/helpers/paramconverter.js index 38b0e24a..7c907bee 100644 --- a/helpers/paramconverter.js +++ b/helpers/paramconverter.js @@ -104,10 +104,10 @@ module.exports = (req, res, next) => { } //moglog date if (req.params.date) { - const dateString = req.params.date.replace(/-/g, '/'); - const date = new Date(dateString); + const [ month, day, year ] = req.params.date.split('-'); + const date = new Date(Date.UTC(year, month, day, 0, 0, 0, 0)); if (date !== 'Invalid Date') { - res.locals.date = date; + res.locals.date = { month, day, year, date }; } } diff --git a/models/pages/modlog.js b/models/pages/modlog.js index c63e9d9f..e10fe1da 100644 --- a/models/pages/modlog.js +++ b/models/pages/modlog.js @@ -9,10 +9,10 @@ module.exports = async (req, res, next) => { return next(); } - const startDate = new Date(res.locals.date); - const endDate = new Date(startDate.valueOf()); - startDate.setHours(0,0,0,0); - endDate.setHours(23,59,59,999); + const startDate = res.locals.date.date; + const { year, month, day } = res.locals.date; + const endDate = new Date(Date.UTC(year, month, day, 23, 59, 59, 999)); + let html; try { const logs = await Modlogs.findBetweenDate(res.locals.board, startDate, endDate);