Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

javashit datetime localization help

Name: homura 2022-02-17 21:58

how do i make
<span class="datetime">1234567890</span>
become <span class="datetime">2009-02-13 18:31</span>
(eg for someone in eastern time; shows in user's local timezone)

pretend i have a lot of <span class="datetime"> scattered about and i want it to either be rendered in local time or in relative "time until" / "time since" units (eg `3 days, 5 hours ago`...)

thanks

Name: Anonymous 2022-02-17 21:59

What programming language is this?

Name: homura 2022-02-17 22:00

>>2
Javascript, obviously. Are you dense?

Name: homura 2022-02-17 22:06

my horsey bf coded this for me :333


Array.from(document.getElementsByClassName('datetime')).map((a) => return a.textContent = new Date(a.textContent).toISOString()

Name: homura 2022-02-17 22:09

this is a date: <span class="datetime">1234567890</span>

<script>
Array.from(document.getElementsByClassName('datetime')).map(a) => return a.textContent = new Date(a.textContent).toISOString()
</script>


IT DOESN'T WORK AAAAAAAA

Name: homura 2022-02-17 22:14

We did it reddit!

this is a date: <span class="datetime">1234567890000</span>
<p>
another date: <span class="datetime">1645136003000</span>

<script>
Array.from(document.getElementsByClassName('datetime')).map((a) => { return a.textContent = new Date(a.textContent-0).toISOString() })
</script>

Name: Anonymous 2022-02-17 22:21

>>6
What if I want to convert it, e.g. to month/day hh:mm (local) ?

Don't change these.
Name: Email:
Entire Thread Thread List