I'm trying to format Javascript datetime, year and month information to something like this:
//"Mon, Nov 5 08:46:20 PM"
To do that, I am following Mozilla documentation here as shown below:
var options = {
weekday: 'short',
month: 'short',
day: 'numeric',
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hour12: true
};
console.log(new Date().toLocaleDateString('en-US', options));
// always returns "Mon, Nov 5, 8:44:10 PM"
Why is the hour in 1-digit format although I specified it as '2-digit'? How can I achieve the format stated in the beginning of this question? Thank you in advance for your answers!