12hrs date format



    The code creates a string which corresponds to the local time on the computer.

    function myFunction() {
      var d = new Date();
      var n = d.toLocaleString([], {hour: '2-digit', minute:'2-digit'});
      document.getElementById("demo").innerHTML = n;
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.