This commit is contained in:
parent
1333195ebe
commit
07266f70a7
1 changed files with 29 additions and 37 deletions
|
|
@ -1,50 +1,42 @@
|
|||
const months = [
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December",
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December",
|
||||
]
|
||||
|
||||
const days = [
|
||||
"Monday",
|
||||
"Tuesday",
|
||||
"Wednesday",
|
||||
"Thursday",
|
||||
"Friday",
|
||||
"Saturday",
|
||||
"Sunday",
|
||||
"Monday",
|
||||
"Tuesday",
|
||||
"Wednesday",
|
||||
"Thursday",
|
||||
"Friday",
|
||||
"Saturday",
|
||||
"Sunday",
|
||||
]
|
||||
|
||||
const convertDate = (isoStamp) => {
|
||||
//const unixSeconds = new Date(isoStamp)
|
||||
//// const weekday = days[unixSeconds.getDay()]
|
||||
//const day = unixSeconds.getDate()
|
||||
//const month = months[unixSeconds.getMonth()]
|
||||
//const year = unixSeconds.getFullYear()
|
||||
//return `${day} ${month} ${year}`
|
||||
|
||||
console.log(isoStamp)
|
||||
const date = new Date(isoStamp)
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, "0")
|
||||
const day = String(date.getDate()).padStart(2, "0")
|
||||
return `${year}-${month}-${day}`
|
||||
const date = new Date(isoStamp)
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, "0")
|
||||
const day = String(date.getDate()).padStart(2, "0")
|
||||
return `${year}-${month}-${day}`
|
||||
}
|
||||
|
||||
const convertDateFriendly = (isoStamp) => {
|
||||
const unixSeconds = new Date(isoStamp)
|
||||
const day = unixSeconds.getDate()
|
||||
const month = months[unixSeconds.getMonth()]
|
||||
const year = unixSeconds.getFullYear()
|
||||
return `${day} ${month} ${year}`
|
||||
const unixSeconds = new Date(isoStamp)
|
||||
const day = unixSeconds.getDate()
|
||||
const month = months[unixSeconds.getMonth()]
|
||||
const year = unixSeconds.getFullYear()
|
||||
return `${day} ${month} ${year}`
|
||||
}
|
||||
|
||||
export { convertDate, convertDateFriendly }
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue