JSFiddle - React, Tailwind, and code Playground

by Alex Tsouloftas

JavaScript

var now= new Date(),
    ampm= 'am',
    h= now.getHours(),
    m= now.getMinutes(),
    s= now.getSeconds();
    if(h>= 12){
        if(h>12)h-= 12;
        ampm= 'pm';
    }
    if(h<10) h= '0'+h;
    if(m<10) m= '0'+m;
    var time = now.toLocaleDateString()+' '+h+':'+m+' '+ampm

   $('body').html(time);