Skip to content

Instantly share code, notes, and snippets.

@willjw3
Last active January 3, 2020 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willjw3/d7737b44c97bf895f6b38490655bf61b to your computer and use it in GitHub Desktop.
Save willjw3/d7737b44c97bf895f6b38490655bf61b to your computer and use it in GitHub Desktop.
const months = {
"01": "January",
"02": "February",
"03": "March",
"04": "April",
"05": "May",
"06": "June",
"07": "July",
"08": "August",
"09": "September",
"10": "October",
"11": "November",
"12": "December"
}
const formatDate = (date) => {
const datetimeArray = date.split("T")
const dateArray = datetimeArray[0].split("-")
const timeArray = datetimeArray[1].split(":")
const month = dateArray[1]
const monthName = months[dateArray[1]]
const day = dateArray[2]
const year = dateArray[0]
const time = `${timeArray[0]}:${timeArray[1]}`
return {"month": month, "monthName": monthName, "day": day, "year": year, "time": time}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment