A
A
Alexander2022-02-17 18:22:36
JavaScript
Alexander, 2022-02-17 18:22:36

Displaying the operating mode according to the day of the week?

Hello. Please tell me the code with which you can display in the top-header block, the operating mode according to the day of the week.

For example, our hours of operation are Monday to Friday from 10:00 to 19:00. When you enter the site on one of these days, there will be a text - Today we work from 10 to 19 hours.

What script is needed, or can it be implemented through a function? Or even better, by adding data to the file responsible for the top header block on the site, or header.php for example.

For example, there is such an option, but it simply displays the current date.

Day today: <?php echo date('l, j F Y'); ?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Arthur, 2016-03-07
@astralo

$('класс ссылки').on('click', function(event){
  event.preventDefault();
  var $el = $(event.currentTarget),
    img = $el.data('target');

  // stop slides
  // fire fancybox
});

A
Artem Zolin, 2022-02-17
@artzolin

$working_hours = [
  '1' => '10:00 — 19:00', // понедельник
  '2' => '10:00 — 19:00',
  '3' => '10:00 — 19:00',
  '4' => '10:00 — 19:00',
  '5' => '10:00 — 20:00', // пятница
  '6' => '10:00 — 15:00', // суббота
  '7' => __( 'Day off', 'textdomain' ) // воскресенье
];

$current_day = date( 'N' );

echo strtr( $current_day, $working_hours );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question