Times
by MegaScience
HTML
<table id="eventTable">
<thead>
<tr>
<th>Function</th>
<th>Date</th>
</tr>
</thead>
<tbody></tbody>
</table>
CSS
td[colSpan] {
text-align: center;
border-bottom: 2px solid black;
}
JavaScript
const funcs = ['toDateString', 'toUTCString', 'toGMTString', 'toISOString', 'toLocaleString', 'toString', 'toTimeString', 'toSource']
const eventDates = [new Date(), new Date('14 Jun 2017 00:00:00 PDT')]
const frag = document.createDocumentFragment()
for (let eventDate of eventDates) {
for (let func of funcs) {
console.log(func, eventDate[func]())
const tr = document.createElement('tr')
const td = [document.createElement('td'), document.createElement('td')]
td[0].textContent = func
td[1].textContent = eventDate[func]()
tr.appendChild(td[0])
tr.appendChild(td[1])
frag.appendChild(tr)
}
const trSep = document.createElement('tr')
const tdSep = document.createElement('td')
tdSep.setAttribute('colSpan', 2)
trSep.appendChild(tdSep)
frag.appendChild(trSep)
}
document.querySelector('table#eventTable tbody').appendChild(frag)