JSFiddle - React, Tailwind, and code Playground

by Сергей Тарасевич

JavaScript

var sss = {
  time: function(a, b, c, d, e, f, g, separatorDate, separatorDateAndTime, separatorTime) {
    var h = new Date(),
      i = '';

    i = (a) ? h.getFullYear() : i;
    i = (b) ? i + ((i !== '') ? separatorDate : '') + ((h.getMonth() - 0) + 1) : i;
    i = (c) ? i + ((i !== '') ? separatorDate : '') + h.getDate() : i;
    i = (d) ? i + ((i !== '') ? separatorDateAndTime : '') + h.getHours() : i;
    i = (e) ? i + ((i !== '') ? separatorTime : '') + h.getMinutes() : i;
    i = (f) ? i + ((i !== '') ? separatorTime : '') + h.getSeconds() : i;
    i = (g) ? i + ((i !== '') ? separatorTime : '') + h.getMilliseconds() : i;

    i = (i === '') ? h : i;

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

    setTimeout(function() {
      sss.time(true, true, true, true, true, true, false, '-', ' ', ':');

    }, 1000);

  }

}

$(document).ready(function() {
  sss.time(true, true, true, true, true, true, false, '-', ' ', ':');

});