how to format date & time in javascript
how do i truncate the
'GMT+0100 (West Africa Standard Time)'
part from my ?
i know of the , but i want the month to stay formatted as text and not numbers?
how do i achieve this, please?

4 Replies
This might be what you're looking for https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString
Date.prototype.toLocaleDateString() - JavaScript | MDN
The toLocaleDateString() method returns a string with a language-sensitive representation of the date portion of the specified date in the user agent's timezone. In implementations with Intl.DateTimeFormat API support, this method simply calls Intl.DateTimeFormat.
When I just want the date (not time) for a
Date, I'll do new Date().toISOString().split('T')[0].
Could you split on ' '?
(Or the toLocaleString is probably better, but more complex to figure out.)This is probably a better idea than splitting that string https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString
Often i find it easier to just use
getHour(), getMinute(), getDay() etc and concatenate the date or time string myself if i want a very specific formatthanks, that's helpful
thank you