-1

<script>
var da = new Date();
document.getElementById("display").innerHTML = da.toDateString();




//gets the current time. 
//var d = new Date();
var x = document.getElementsByClassName("start")[0].innerText;
var z = document.getElementsByClassName("end")[0].innerText;
//var o = parseInt(x,10);
//var c = parseInt(z,10);

var startTime = Date.parseExact(x, "h:mm tt");
var endTime = Date.parseExact(z, "h:mm tt");

if (da.between(startTime, endTime)){
    $(".open").show();
    $(".closed").hide();
}
else {  
    $(".closed").show();
    $(".open").hide();
}
// how can I show the closed class on Sunday?
// How can I show the open class  from 9:00 am to 19:00 pm?

</script>

can anyone help me how to create a message on my header to show when the shop is open or close?

For example, I want from Monday-Friday from (9:00-19:00) to show an html message that the store is open. For Saturday from (9:00-16:00) Otherwise a message will show that the store is closed. Something like that: http://i.imgur.com/eHH8Um3.png

okay I am trying to understand the above code but I need some help see comments of the code to the end of the code

But how can I show/hide something on Sunday? I am a little new to javascript

1 Answers1

0

you can use this and throw a ifcondition for checking according to your requirements

 function get_the_local_time($timezone) {

//$timezone ='Europe/London';

$date = new DateTime('now', new DateTimeZone($timezone));

return array(
    'local-machine-time' => $date->format('Y-m-d\TH:i:s+0000'),
    'local-time' => $date->format('h:i a')
);

 }
Sriker Ch
  • 133
  • 11