"Hours"
Bootstrap 3.3.0 Snippet by waffleamp

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <span class="glyphicon glyphicon-time"></span> </br> <div id="timeDiv"></div>
.glyphicon { font-size:1.5em; position: relative; max-width: 175px; width: 100%; display: inline-block; vertical-align: middle; text-align: center; background: #EFEFEF; } #timeDiv { font-size: 15px; text-transform: uppercase; position: relative; max-width: 175px; background: #EFEFEF; width: 85%; margin: 0 auto; top: 50%; padding: 10px; display: inline-block; vertical-align: middle; font-weight: 600; text-align: center; }
var now = new Date(); var weekday = new Array(7); weekday[0] = "Sunday"; weekday[1] = "Monday"; weekday[2] = "Tuesday"; weekday[3] = "Wednesday"; weekday[4] = "Thursday"; weekday[5] = "Friday"; weekday[6] = "Saturday"; var checkTime = function() { var today = weekday[now.getDay()]; var timeDiv = document.getElementById('timeDiv'); var dayOfWeek = now.getDay(); var hour = now.getHours(); var minutes = now.getMinutes(); //add AM or PM var suffix = hour >= 12 ? "PM" : "AM"; // add 0 to one digit minutes if (minutes < 10) { minutes = "0" + minutes }; if ((dayOfWeek == 1 || dayOfWeek == 2 || dayOfWeek == 3 || dayOfWeek == 4) && hour >= 0 && hour <= 24) { hour = ((hour + 11) % 12 + 1); //i.e. show 1:15 instead of 13:15 timeDiv.innerHTML = today +''s' + ' ' + ' hours 8am-1am'; } else if ((dayOfWeek == 5) && hour >= 0 && hour <= 24) { hour = ((hour + 11) % 12 + 1); timeDiv.innerHTML = today +''s' + ' ' + ' hours 8am-5pm'; } else if ((dayOfWeek == 6) && hour >= 0 && hour <= 24) { hour = ((hour + 11) % 12 + 1); timeDiv.innerHTML = today +''s' + ' ' + ' hours 9am-5pm'; timeDiv.className = 'open'; } else if ((dayOfWeek == 0) && hour >= 0 && hour <= 24) { hour = ((hour + 11) % 12 + 1); timeDiv.innerHTML = today +''s' + ' ' + ' hours 1pm-1am'; } else { if (hour == 0 || hour > 12) { hour = ((hour + 11) % 12 + 1); //i.e. show 1:15 instead of 13:15 } timeDiv.innerHTML = 'closed'; timeDiv.className = 'closed'; } }; var currentDay = weekday[now.getDay()]; var currentDayID = "#" + currentDay; //gets todays weekday and turns it into id $(currentDayID).toggleClass("today"); //hightlights today in the view hours modal popup setInterval(checkTime, 1000); checkTime();

Related: See More


Questions / Comments: