Hey my friend :) this is my approach:
const formatDate = (date) => {
const newDate = new Date(date);
const day = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(newDate);
const month = new Intl.DateTimeFormat('en', {month: 'short' }).format(newDate);
const year = new Intl.DateTimeFormat('en', {year: 'numeric'}).format(newDate);
return `Joined ${day} ${month} ${year}`;
}
You take the date from the Github API and make an new Date opject. With "Intl.DateTimeForma"t you have several options to format the date.
Here on MDN Webdoc, you have a more detailed explenation.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat
Have a good day :)
Marked as helpful
@BenjaDotMin
Posted
@astragenius I really appreciate this, thanks so much!
Code updated and credited.