F
F
Farik Azizov2018-11-21 06:48:59
PHP
Farik Azizov, 2018-11-21 06:48:59

How to use PHP or JS to show a div on specific days?

Welcome all!
For example I have a div, I want to show this div every year from November 21st to 25th.
How to implement this with PHP or JS?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2018-11-21
@bizpartneer

$today = strtotime(date("Y-m-d"));
$begin = strtotime(date("Y-11-21"));
$end = strtotime(date("Y-11-25"));

if($today >= $begin && $today <= $end) {
   echo "Показываем div";
}

P
Petr Vasiliev, 2018-11-21
@danial72

Php
<? If(date("m") == "11" and (21 <= intval(date("d")) <= 25):?>
Div some ....
<?endif;?>
The principle is this. But in general, there are mechanisms in the site engine, it is better to use them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question