Last active
January 3, 2020 08:50
-
-
Save willjw3/d7737b44c97bf895f6b38490655bf61b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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