How to get the beginning and end of the day in Node.js

1 Answer

0 votes
const moment = require('moment');

const startOfDay = moment().startOf('day');
console.log("Start of Day:", startOfDay.format("YYYY-MM-DD HH:mm:ss"));

const endOfDay = moment().endOf('day');
console.log("End of Day:", endOfDay.format("YYYY-MM-DD HH:mm:ss"));



/*
run:

Start of Day: 2025-12-12 00:00:00
End of Day: 2025-12-12 23:59:59

*/

 



answered Dec 12, 2025 by avibootz
...