TL;DR
Here's the code:
const options = {
year: 'numeric',
month: 'numeric',
day: 'numeric',
weekday: 'long',
hour: 'numeric',
minute: 'numeric',
};
const dt = new Date('2023-06-16T12:00:00Z');
const formattedDate = `${dt.toLocaleDateString('en-GB', {
year: 'numeric',
month: 'numeric',
day: 'numeric',
})}, ${dt.toLocaleDateString('en-GB', {
weekday: 'long',
})}, ${dt.toLocaleTimeString('en-GB', {
hour: 'numeric',
minute: 'numeric',
})}`;
console.log(formattedDate);
Since I could only go half trough the answer, here is a link where I've found the whole one.
Firstly, I've added weekday, hour and minute
inside the options
, and changed the locale
to en-GB
(for desired slashes ( / ) DD/MM format).
So this was the result.
const options = {
year: 'numeric',
month: 'numeric',
day: 'numeric',
weekday: 'long',
hour: 'numeric',
minute: 'numeric',
};
const dt = new Date('2023-06-16T12:00:00Z').toLocaleDateString('en-GB', options)
console.log(dt)
Then, as I mentioned, an user showed me how to format the date even more, like so, and we got the desired output.
const formattedDate = `${dt.toLocaleDateString('en-GB', {
year: 'numeric',
month: 'numeric',
day: 'numeric',
})}, ${dt.toLocaleDateString('en-GB', {
weekday: 'long',
})}, ${dt.toLocaleTimeString('en-GB', {
hour: 'numeric',
minute: 'numeric',
})}`;