Display the current time

RMAG news

Goal: 01 / 01 / 2000, 12:00

const now = new Date();
const day = `${now.getDate()}`.padStart(2, ‘0’);
const month = `${now.getMonth() + 1}`.padStart(2, ‘0’);
const year = now.getFullYear();
const hour = now.getHours();
const min = now.getMinutes();

padStart() needs to be used with a string.
padStart() fills the first argument’s number of minutes with the elements of the second argument.

hoge.textContent = `${day}/${month}/${year}, ${hour}:${min}`;