Date formats/ timestamps can be tricky to handle in JavaScript, especially when it comes to time zones. This post explains how I deal with converting timestamps and the libraries I use in React.
new Date('2020-03-15')
new Date('03/15/2020')
new Date('2020/03/15')
new Date('2020/3/15')
new Date('March 15, 2020')
new Date('March 15, 2020 19:03:21')
new Date('2020-03-15 19:03:21')
new Date('2020-03-15T19:03:21')
new Date('15 March 2020')
new Date('15 Mar 2020')
new Date('15 March, 2020')
new Date('March 15, 2020')
new Date('March 15 2020')
// Timezones
new Date('March 15, 2020 19:03:21 (GMT)')
const date = new Date('March 15, 2020 19:03:21')
date.toString()
date.toTimeString()
date.toUTCString()
date.toDateString()
date.toLocaleString()
date.toLocaleTimeString()
date.getTime()
const day = moment.unix(1318781876)
moment.unix(yourUnixEpochTime).format('dddd, MMMM Do, YYYY h:mm:ss A')
import fromUnixTime from 'date-fns/fromUnixTime'
fromUnixTime(unixTime)
import format from 'date-fns/format'
format(date, format, [options])