Automatic day information / calendar note


(Anders O Blomberg) #1

I manage a web site for a museum railway. We would like to put a headline on our first page:
Today we are open
or
Today we are closed
based on a calendar we have. Or on a list of open dates?
Any advice much appreciated!
Anders


(Hans-Gerd Claßen) #2
var now = new Date();
var nowIso = now.toISOString().split('T')[0]; //will result in year-month-day ... 2017-01-29

so if you’ve got an array
var _closed = ['2017-04-05', 'next date']

you can check
if(_closed.indexOf(nowIso) != -1)alert('today closed')