···118118 }
119119120120 // if in the last day
121121- if (now.toISOString().slice(0, 10) === date.toISOString().slice(0, 10)) {
121121+ if (localDateString(now) === localDateString(date)) {
122122 return time
123123 }
124124125125 // if yesterday
126126 const yesterday = new Date(now)
127127 yesterday.setDate(yesterday.getDate() - 1)
128128- if (
129129- yesterday.toISOString().slice(0, 10) === date.toISOString().slice(0, 10)
130130- ) {
128128+129129+ if (localDateString(yesterday) === localDateString(date)) {
131130 return _(msg`Yesterday, ${time}`)
132131 }
133132···164163 </TimeElapsed>
165164 )
166165}
166166+167167+function localDateString(date: Date) {
168168+ // can't use toISOString because it should be in local time
169169+ const mm = date.getMonth()
170170+ const dd = date.getDate()
171171+ const yyyy = date.getFullYear()
172172+ // not padding with 0s because it's not necessary, it's just used for comparison
173173+ return `${yyyy}-${mm}-${dd}`
174174+}