Using moment.js you can do this, which will give you exactly what you asked for:
const start = moment().startOf('day'); const times = 24 * 4; // 24 hours * 15 mins in an hour for (let i = 0; i < times; i++) { const toPrint = moment(start) .add(15 * i, 'minutes') .format('hh:mm A'); console.log(toPrint); }
<script src="https://unpkg.com/moment@2.24.0/moment.js"></script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.