cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
                <body onload="startTime()">
    <div class="container">
      <div class="clockArea">
        <p class="topText">Today is:</p>
        <div id="whatDate"></div>
        <p class="topText">The Time is:</p>
        <div id="clock"></div>
      </div>
    </div>
  </body>
            
          
!
            
                  body{
      margin:0;
      padding:0;
      font-size: 18px;
      background:black;
    }
    .container{
      position:relative;
      height: 700px;
    }
    .clockArea {
      position:absolute;
      top:50%;
      left:50%;
      transform: translate(-50%,-50%);
    }
    .topText{
      font-family: 'Orbitron', sans-serif;
      color: lightslategrey;
      font-style: italic;
      text-align: center;
      font-size: 1.5em;
    }
    #whatDate {
      font-family: 'Orbitron', sans-serif;
      font-size: 5em;
      margin:20px auto;
      color: limegreen;
      font-style: italic;
      text-align: center;
    }
    #clock {
      font-family: 'Orbitron', sans-serif;
      font-size: 7.5em;
      margin:20px auto;
      color: limegreen;
      font-style: italic;
      text-align: center;
      min-width: 1000px;
      margin-top: -20px;
    }
    @media screen and (max-width:1000px){
      #whatDate, #clock {
        font-size: 2em;
      }
      .container{
        height: 600px;
      }
      .topText {
        margin-bottom: inherit;
      }
      .clockArea {
        position:relative;
        top:inherit;
        left:inherit;
        transform: translate(0%,20%);
      }
      #clock{
        min-width: inherit;
        margin-top: 20px;
      }
    }
            
          
!
            
                  function startTime() {
        var today = new Date();
        var h = today.getHours();
        var m = today.getMinutes();
        var s = today.getSeconds();
        var ampm = h >= 12 ? 'PM' : 'AM'; // Display AM or PM
        m = checkTime(m);
        s = checkTime(s);
        //Convert to 12-hour (non-military time)
        if (h > 12) {
        h -= 12;
        } else if (h === 0) {
            h = 12;
        };
        document.getElementById('clock').innerHTML =
        h + ":" + m + ":" + s + " " + ampm;
        var t = setTimeout(startTime, 500);

        var todayDate = new Date();
        var dd = todayDate.getDate();
        var mm = todayDate.getMonth()+1; //January is 0!
        var yyyy = todayDate.getFullYear();
        if(dd<10) {
            dd = '0' + dd
        }
        if(mm<10) {
            mm = '0' + mm
        };
        document.getElementById('whatDate').innerHTML = mm + '/' + dd + '/' + yyyy;
    }

    function checkTime(i) {
        if (i < 10) {i = "0" + i};  // add zero in front of numbers < 10
        return i;
    }
            
          
!
999px
Loading ..................

Console