function localtime(datestring) { var date = new Date(datestring); var now = new Date(); var day =''; if ( date.getDate() === now.getDate() ) { day='TODAY'; options = { timeStyle: "short"}; console.log('today'); return ('TODAY '+Intl.DateTimeFormat('en-US', { dateStyle: undefined, hour: 'numeric', minute: 'numeric', timeZoneName: 'short'}).format(date)); } return (Intl.DateTimeFormat('en-US', { weekday: 'long', dateStyle: undefined, hour: 'numeric', minute: 'numeric', timeZoneName: 'short'}).format(date)); } document.addEventListener("DOMContentLoaded", function() { const utctimes = document.getElementsByClassName("utctime"); for ( var i = 0; i < utctimes.length; i++) { console.log(utctimes[i].innerHTML); utctimes[i].innerHTML=localtime(utctimes[i].innerHTML); } });