<For each={prices()}> {(price, index) => { return <tr class="grid grid-cols-4"> <td><RelativeTime millis={price.milliseconds}/></td> </tr> }}</For>
function getRelativeTime(millis: number) { const diff = DateTime.now().diff(DateTime.fromMillis(millis)).milliseconds; return ms(diff > 0 ? diff : 0, { long: true });}export function RelativeTime({ millis, updateInterval = 1000,}: CurrencyProperties) { const [currentMillis, setCurrentMillis] = createSignal(getRelativeTime(millis)); createEffect(() => { const interval = setInterval(() => { setCurrentMillis(getRelativeTime(millis)); }, updateInterval); onCleanup(() => { clearInterval(interval) }) }); return currentMillis();}