Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Live Time Opening Hours?! Rate Topic   * * * * * 1 votes

 
  • Anaconda
  • Senior Member
  • Members
  • Join Date: 19-Sep 14
  • 151 posts

Posted 22 October 2014 - 05:48 PM #1

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.

Attached Files

  • Attached File  time.png   2.32KB   21 downloads


 
  • Anaconda
  • Senior Member
  • Members
  • Join Date: 19-Sep 14
  • 151 posts

Posted 22 October 2014 - 06:36 PM #2

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
<script src="http://www.yoursite.com/js/todayshours.js"></script>
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 = "<strong>Vandaag:</strong> " + openTime + " tot " + closeTime;
   document.write(libhours);
  }
}

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

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1271 posts

Posted 23 October 2014 - 05:54 AM #3

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 += '<span style="color:#f00">We are not open yet!</span><br/>';
   }else if(_current_time > _close_time ){
       _html += '<span style="color:#f00">We close!</span><br/>';
   }   

   _html += "<strong>Vandaag:</strong> " + openTime + " tot " + closeTime;
  }

document.write(_html);
}

I hope that helps,

---
Valentin
part of hungryweb.net

 
  • globalburo
  • Junior Member
  • Members
  • Join Date: 16-Mar 11
  • 138 posts

Posted 23 October 2014 - 08:43 AM #4

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 ?

 
  • Anaconda
  • Senior Member
  • Members
  • Join Date: 19-Sep 14
  • 151 posts

Posted 23 October 2014 - 04:37 PM #5

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 += '<span style="color:#f00">We are not open yet!</span><br/>';
   }else if(_current_time > _close_time ){
	   _html += '<span style="color:#f00">We close!</span><br/>';
   }  

   _html += "<strong>Vandaag:</strong> " + openTime + " tot " + closeTime;
  }

document.write(_html);
}

I hope that helps,

---
Valentin
part of hungryweb.net


Thank you verry much Vali. We close! works :-), but the open now text shows nothing.

 
  • Anaconda
  • Senior Member
  • Members
  • Join Date: 19-Sep 14
  • 151 posts

Posted 23 October 2014 - 04:52 PM #6

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 ?

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.
<script src="http://www.yoursite.com/js/todayshours.js"></script>

Is this what you mean?

 
  • globalburo
  • Junior Member
  • Members
  • Join Date: 16-Mar 11
  • 138 posts

Posted 23 October 2014 - 09:16 PM #7

Tank you work

 
  • pepinos
  • Junior Member
  • Members
  • Join Date: 19-Aug 06
  • 8 posts

Posted 26 November 2014 - 01:41 AM #8

Thank you guys, very nice script.

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

Thanks!

 
  • Anaconda
  • Senior Member
  • Members
  • Join Date: 19-Sep 14
  • 151 posts

Posted 26 November 2014 - 07:48 PM #9

Thank you guys, very nice script.

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

Thanks!

Its start from sunday, monday, etc.
For closing day time = X
You could try this to use
10am and 6pm

 
  • pepinos
  • Junior Member
  • Members
  • Join Date: 19-Aug 06
  • 8 posts

Posted 27 November 2014 - 12:59 AM #10

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.

 
  • Anaconda
  • Senior Member
  • Members
  • Join Date: 19-Sep 14
  • 151 posts

Posted 27 November 2014 - 05:17 PM #11

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.


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.

 
  • pepinos
  • Junior Member
  • Members
  • Join Date: 19-Aug 06
  • 8 posts

Posted 01 December 2014 - 11:34 PM #12

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

 
  • b4lly
  • Junior Member
  • Members
  • Join Date: 29-Oct 08
  • 81 posts

Posted 10 December 2014 - 11:35 PM #13

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 += '<span style="color:#81cc60" > OPEN: </span>';
   }else {
	   _html += '<span style="color:#FE2E2E"> CLOSED: </span>';
   }  
   _html += " hours " + openTime + " to " + closeTime;
  }
document.write(_html);
}