Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

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.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <head>
  <tittle> Random clock</tittle>
  <link href="https://fonts.googleapis.com/css2?family=Noto+Sans&display=swap" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css2?family=Fredoka+One&display=swap" rel="stylesheet">


</head>
<body>
 
  <h2 id="funny-intro" class ="intro"> It's time to</h2>

<div id="clock">clock goes here</div>

  <div class="container">
  <img id="funny-pic" src="https://images.unsplash.com/photo-1495214783159-3503fd1b572d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" alt="breakfast">
  <div id="time-event" class= "text-block"> It's breakfast time</div>
  </div>  
  <!--Set breakfast-->
<label for="setwakeup">Set wake up time:</label>
  <select id="setwakeup">
        <option value="5"> 5-6am</option>
    <option value="6"> 6-7am</option>
    <option value="7"> 7-8am</option>
    <option value="8"> 8-9am</option>
    <option value="9"> 9-10am</option>
    <option value="10"> 10-11am</option>
  </select>
  <br>
  <!--Set luch time-->
  <label for="setlunchtime">Set lunch time:</label>
  <select id="setlunchtime">
        <option value="10"> 10-11am</option>
    <option value="11"> 11-12pm</option>
    <option value="12"> 12-1pm</option>
    <option value="13"> 1-2pm</option>
    <option value="14"> 2-3pm</option>

  </select>
  <br>
  <!--set dinner time-->
  <label for="setdinner">Set dinner time:</label>
  <select id="setdinner">
        <option value="16"> 4-5pm</option>
    <option value="17"> 5-6pm</option>
    <option value="18"> 6-7pm</option>
    <option value="19"> 7-8pm</option>
    <option value="20"> 8-9pm</option>
    <option value="21"> 9-10pm</option>
  </select>
  <br>
  <!-- set break time-->
  <label for="setbreaktime">Set breaktime:</label>
  <select id="setbreaktime">
        <option value="11"> 11-12am</option>
    <option value="12"> 12-1pm</option>
    <option value="13"> 1-2pm</option>
    <option value="14"> 2-3pm</option>
    <option value="21"> 9-10pm</option>
    <option value="22"> 10-11pm</option>
  </select>
 <br>
  <button id="party"> Let's party time</button>
</body>

  

      



      

  

      

  
              
            
!

CSS

              
                body{background-color:#EEE8AA;
}
tittle{font-family: 'Fredoka One', cursive;
  font-size:4em;
}
body{text-align: center;
     font-family: 'Noto Sans', sans-serif;
}
 #clock { color:black;
  font-size: 40px;
  display: block;
   padding: 5px 0px}
.container{position:relative;
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 50%;
           }
img{max-width:99%;}
.text-block {font-size:2em;
  position: absolute;
  margin-left:35%;
  bottom: 30px;
  background-color: black;
  color: white;
  padding-left: auto;
  padding-right: auto;}
button{  background-color: #222;
         width:200px;
         height:40px;
         color:white;
         font-size:1.2em;
         margin: 20px;
}

              
            
!

JS

              
                var time = new Date().getHours();
 var wakeuptime = 7;
var noon = 12;
var partytime;
var dinnertime = 19;
var lunchtime = 12;
var breaktime = lunchtime + 2;
var evening = 18;
var partytime;


//show the clock on page
var startTime = function () {var today = new Date();
  var hours = today.getHours();
  var mins = today.getMinutes();
  var secs = today.getSeconds();
  mins = checkTime(mins);
  secs = checkTime(secs);
  var timeOfDay = (hours < 12)? "AM":"PM" ;
  hours = ( hours > 12 ) ? hours - 12 : hours;

  // get the clock string
document.getElementById('clock').innerHTML =   hours + ":" + mins + ":" + secs   + timeOfDay;

  function checkTime (i){ if (i < 10)
                        {i = "0" + i ;}
                        return i;}
 
};
// Getting the clock to increment once a second
var oneSecond = 1000;
setInterval( upDateClock, oneSecond);

// Getting the clock to change out messages and pictures
var upDateClock = function(){

 var message;
  var image = "https://images.unsplash.com/photo-1495214783159-3503fd1b572d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" ;
  var timeEvent = document.getElementById('time-event');
  var imageJS = document.getElementById('funny-pic');
  
 //morning image and message
  if (time < noon ){message = "Good morning";
                     image = "https://images.unsplash.com/photo-1446844805183-9f5af45f89ee?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=667&q=80";}
  // wakeuptime
  else if (time == wakeuptime){message = "It's breakfast time";
                                }
  //partytime image and message
   
  else if (time == partytime){message = "YAY";
                              image = "https://images.unsplash.com/photo-1513151233558-d860c5398176?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60";}
  
  //evening
  else if (time >= evening ){message = "Good evening";
                             image = "https://images.unsplash.com/photo-1532767153582-b1a0e5145009?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=334&q=80";}
  //lunch
  else if (time == lunchtime ){message = "Let's have lunch";
                               image = "https://images.unsplash.com/photo-1475090169767-40ed8d18f67d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=889&q=80";}
  // break
  else if (time == breaktime){message = "Let's have a break";
                              image = "https://images.unsplash.com/photo-1421882402971-b18cd1741ac6?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=888&q=80";}
  //diner
  else if (time == dinnertime){message = "let's have dinner";
                                image = "https://images.unsplash.com/photo-1519671282429-b44660ead0a7?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1500&q=80";}
  //Don't think I need this
  //noon
  else {message = "Good afternoon";
                                          image = "https://images.unsplash.com/photo-1579458886732-18450c89ab0c?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80";}
  // console it out
  console.log(message); 
  timeEvent.innerText = message;
  imageJS.src = image;
  startTime();
};
upDateClock();

// Getting the clock to increment once a second
var oneSecond = 1000;
setInterval( upDateClock, oneSecond);

// change party button
var partyButton = document.getElementById("party");
var partytime;
 var partyEvent = function()
{if (partytime < 0) 
    {
        partytime = new Date().getHours();
                                 party.innerText = "It's over";}
                else {partytime = -1;
                     party.innerText = "Party time";}};
partyButton.addEventListener("click", partyEvent);
partyEvent(); 

// active set wake up time
var setWakeUp = document.getElementById("setwakeup");
var wakeupEvent = function (){ wakeuptime = setWakeUp.value;};

setWakeUp.addEventListener("change", wakeupEvent);
// active set lunch time
var setLunchTime = document.getElementById("setlunchtime");
var lunchtimeEvent = function (){ lunchtime = setLunchTime.value;};

setLunchTime.addEventListener("change", lunchtimeEvent);
// active dinner time
var setDinnerTime = document.getElementById("setdinner");
var dinnerEvent = function(){dinnertime = setDinnerTime.value;};
setDinnerTime.addEventListener("change",dinnerEvent);


              
            
!
999px

Console