var epochtime = "1610950344"; var datevar = new Date(epochtime *1000); var mytime = datevar.toISOString().slice(0, 19).replace(\'T\', \' \'); console.log(&