Live Time Opening Hours?!

Hello



I have been looking for a code to insert on my store, but did not found one.



I want to have a live time opening hours for the real store.

Facebook have this, its shows when the real store is open till xx time or show closed when visited after closing time.



I hope you understand me. Sorry for my bad english.



Kindley regards.

time.png

I have already this js file uploaded to my ftp js folder and inserted the path url in a block.

But i missing the Closed or Open option.

Example: Closed for now or Open Now.



Code for block

```php


```

todayshours js file


var open=["X","X","10u00","10u00","10u00","10u00","10u00"]; // Edit this line
var close=["X","X","20u00","18u00","18u00","18u00","18u00"]; // Edit this line

var currentTime = new Date()
var day = currentTime.getDay()
var openTime = open[day];
var closeTime = close[day];
createHours(openTime,closeTime);

function createHours(openTime, closeTime)
{ // Build the hours string
if(openTime == "X") {
var libhours = "Gesloten";
document.write(libhours);
} else {
var libhours = "Vandaag: " + openTime + " tot " + closeTime;
document.write(libhours);
}
}




Hope sombody can help me. For adding closed for now and open now

Hi @Anaconda,



Please try var open=["X","X","10u00","10u00","10u00","10u00","10u00"]; // Edit this line
var close=["X","X","20u00","18u00","18u00","18u00","18u00"]; // Edit this line

var currentTime = new Date()
var day = currentTime.getDay()-1;
var openTime = open[day];
var closeTime = close[day];
createHours(openTime,closeTime);

function createHours(openTime, closeTime){ // Build the hours string
var _html = '';
if(openTime == "X") {
_html += "Gesloten";
} else {
var _current_time = parseFloat(currentTime.getHours()+'.'+currentTime.getMinutes());
var _open_time = parseFloat(openTime.replace('u','.'));
var _close_time = parseFloat(closeTime.replace('u','.'));
if(_current_time < _open_time ){
_html += 'We are not open yet!
';
}else if(_current_time > _close_time ){
_html += 'We close!
';
}

_html += "Vandaag: " + openTime + " tot " + closeTime;
}

document.write(_html);
}




I hope that helps,





Valentin

[color=#808080][size=2]part of hungryweb.net[/size][/color]

hello guys

I want say kargo time similar

But I dont know which path add todayshours.js

How can I get it to appear on the obverse ?

[quote name=‘Vali’ timestamp=‘1414043653’ post=‘194954’]

Hi @Anaconda,



Please try ```php
var open=[“X”,“X”,“10u00”,“10u00”,“10u00”,“10u00”,“10u00”]; // Edit this line

var close=[“X”,“X”,“20u00”,“18u00”,“18u00”,“18u00”,“18u00”]; // Edit this line



var currentTime = new Date()

var day = currentTime.getDay()-1;

var openTime = open[day];

var closeTime = close[day];

createHours(openTime,closeTime);



function createHours(openTime, closeTime){ // Build the hours string

var _html = ‘’;

if(openTime == “X”) {

_html += “Gesloten”;

} else {

var _current_time = parseFloat(currentTime.getHours()+‘.’+currentTime.getMinutes());

var _open_time = parseFloat(openTime.replace(‘u’,‘.’));

var _close_time = parseFloat(closeTime.replace(‘u’,‘.’));

if(_current_time < _open_time ){

_html += ‘We are not open yet!
’;

}else if(_current_time > _close_time ){

_html += ‘We close!
’;

}



_html += "Vandaag: " + openTime + " tot " + closeTime;

}



document.write(_html);

}

<br />
I hope that helps,<br />
<br />
---<br />
Valentin<br />
[color=#808080][size=2]part of hungryweb.net[/size][/color]<br />
[/quote]<br />
<br />
Thank you verry much Vali. We close! works <img src="upload://b6iczyK1ETUUqRUc4PAkX83GF2O.gif" class="bbc_emoticon" alt=":-)">, but the open now text shows nothing.

[quote name='globalburo' timestamp='1414053784' post='194984']

hello guys

I want say kargo time similar

But I dont know which path add todayshours.js

How can I get it to appear on the obverse ?

[/quote]

Upload to Folder location:

Trough Ftp - cscart / js and past this code in a block for showing where you like.

Just change the url to you'r site name.

```php


```



Is this what you mean?

Tank you work

Thank you guys, very nice script.



And what if I need to have a format like 10.00 AM to 6.00 PM ?



Thanks!

[quote name='pepinos' timestamp='1416966084' post='197972']

Thank you guys, very nice script.



And what if I need to have a format like 10.00 AM to 6.00 PM ?



Thanks!

[/quote]

Its start from sunday, monday, etc.

For closing day time = X

You could try this to use

10am and 6pm

Thanks but this does not work… BTW it's start from monday. I think there needs to be use format like (

date +“%p”) but I trying and can't find a solution how.

Thank you.

[quote name='pepinos' timestamp='1417049988' post='198091']

Thanks but this does not work… BTW it's start from monday. I think there needs to be use format like (

date +“%p”) but I trying and can't find a solution how.

Thank you.

[/quote]



Enter the time your store opens, starting with Sunday. If your store is closed, enter “X” for the time.


var open=["X","10:00am","10:00am","10:00am","10:00am","10:00am","12:00am"];


Enter the time when closes, starting with Sunday. If your store is closed, enter “X” for the time.


var closed=["X","6:00pm","6:00pm","6:00pm","6:00pm","6:00pm","1:30pm"];




Hope this help you further, i'm not a java-writter, but this works on my server.

Thanks @Anaconda but it's does not work on my server, using iPage.

I have this script working well with a few small tweaks…

_________________________________________________________________

var open=["09.30","09.30","09.30","09.30","09.30","09.30","09.30"]; // Edit this line
var close=["15.00","17.00","17.00","17.00","17.00","17.00","17.00"]; // Edit this line

var currentTime = new Date()
var day = currentTime.getDay();
var openTime = open[day];
var closeTime = close[day];
createHours(openTime,closeTime);
function createHours(openTime, closeTime){ // Build the hours string
var _html = '';
if(openTime == "X") {
_html += "closed today";
} else {
var _current_time = parseFloat(currentTime.getHours()+'.'+currentTime.getMinutes());
var _open_time = parseFloat(openTime.replace('u','.'));
var _close_time = parseFloat(closeTime.replace('u','.'));
if(_current_time < _close_time && _current_time > _open_time ){
_html += ' OPEN: ';
}else {
_html += ' CLOSED: ';
}
_html += " hours " + openTime + " to " + closeTime;
}
document.write(_html);
}