Set a style with Javascript
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
document.getElementById('id_goes_here').style.display = 'none';
document.getElementById('id_goes_here').style.display = 'none';
document.getElementById('id_goes_here').style.display = 'none';
Print Page to the Printer
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
print();
print();
print();
Javascript countdown timer for the difference between two dates
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
let timer = setInterval(function() {
// The dispatch date is just the variable name. You can change it wo whatever. As long as you change it where ever else it is been used as well.
// the format for dispatch_date is ('2018-10-17 17:00:00') which is been pull from an input field with the id of "countdown_timer"
const dispatch_date = new Date(document.getElementById("countdown_timer").value);
const today = new Date();
// console.log("dispatch_date : "+dispatch_date);
// console.log("today : "+today);
// get the difference
const diff = dispatch_date - today;
// math
let days = Math.floor(diff / (1000 * 60 * 60 * 24));
let hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
let minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
let seconds = Math.floor((diff % (1000 * 60)) / 1000);
// display
document.getElementById("timer").innerHTML =
//Days - Hours - Minutes - Seconds
"</div class='timer-p'>This Stock list Expires in </div> \ <div class=\"days\"> \
<div class=\"numbers\">" + days + "</div>Days</div> \
<div class=\"hours\"> \
<div class=\"numbers\">" + hours + "</div>Hours</div> \
<div class=\"minutes\"> \
<div class=\"numbers\">" + minutes + "</div>Minutes</div> \
<div class=\"seconds\"> \
<div class=\"numbers\">" + seconds + "</div>Seconds</div> \
</div>";
}, 1000);
let timer = setInterval(function() { // The dispatch date is just the variable name. You can change it wo whatever. As long as you change it where ever else it is been used as well. // the format for dispatch_date is ('2018-10-17 17:00:00') which is been pull from an input field with the id of "countdown_timer" const dispatch_date = new Date(document.getElementById("countdown_timer").value); const today = new Date(); // console.log("dispatch_date : "+dispatch_date); // console.log("today : "+today); // get the difference const diff = dispatch_date - today; // math let days = Math.floor(diff / (1000 * 60 * 60 * 24)); let hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); let minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60)); let seconds = Math.floor((diff % (1000 * 60)) / 1000); // display document.getElementById("timer").innerHTML = //Days - Hours - Minutes - Seconds "</div class='timer-p'>This Stock list Expires in </div> \ <div class=\"days\"> \ <div class=\"numbers\">" + days + "</div>Days</div> \ <div class=\"hours\"> \ <div class=\"numbers\">" + hours + "</div>Hours</div> \ <div class=\"minutes\"> \ <div class=\"numbers\">" + minutes + "</div>Minutes</div> \ <div class=\"seconds\"> \ <div class=\"numbers\">" + seconds + "</div>Seconds</div> \ </div>"; }, 1000);
let timer = setInterval(function() {

  // The dispatch date is just the variable name. You can change it wo whatever. As long as you change it where ever else it is been used as well.  
  // the format for dispatch_date is ('2018-10-17 17:00:00') which is been pull from an input field with the id of "countdown_timer"
  const dispatch_date = new Date(document.getElementById("countdown_timer").value);
  const today = new Date();
  
  // console.log("dispatch_date : "+dispatch_date);
  // console.log("today : "+today);

  // get the difference
  const diff = dispatch_date - today;

  // math
  let days = Math.floor(diff / (1000 * 60 * 60 * 24));
  let hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  let minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
  let seconds = Math.floor((diff % (1000 * 60)) / 1000);

  // display
  document.getElementById("timer").innerHTML =

  //Days - Hours - Minutes - Seconds
    "</div class='timer-p'>This Stock list Expires in </div> \ <div class=\"days\"> \
  <div class=\"numbers\">" + days + "</div>Days</div> \
<div class=\"hours\"> \
  <div class=\"numbers\">" + hours + "</div>Hours</div> \
<div class=\"minutes\"> \
  <div class=\"numbers\">" + minutes + "</div>Minutes</div> \
<div class=\"seconds\"> \
  <div class=\"numbers\">" + seconds + "</div>Seconds</div> \
</div>";

}, 1000);
PHP check if an item is inside a multi dimensional array

Here’s the Stackoverflow link

Here’s the improved answer

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
//The Function
function in_array_r($needle, $haystack, $strict = false) {
foreach ($haystack as $item) {
if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_array_r($needle, $item, $strict))) {
return true;
$found = 'yes';
}
}
$found = 'no';
return false;
}
//The Function in use
//Set the result as a var so you can check it.
$found = in_array_r($search_pre_order_date,$dates_array) ? 'found' : 'not found';
//If the result is equal to something do something...
if ($found == 'found') {
echo 'Yes this item is in the array';
}elseif ($found == 'not found') {
echo 'Nope not in the array';
}
//The Function function in_array_r($needle, $haystack, $strict = false) { foreach ($haystack as $item) { if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_array_r($needle, $item, $strict))) { return true; $found = 'yes'; } } $found = 'no'; return false; } //The Function in use //Set the result as a var so you can check it. $found = in_array_r($search_pre_order_date,$dates_array) ? 'found' : 'not found'; //If the result is equal to something do something... if ($found == 'found') { echo 'Yes this item is in the array'; }elseif ($found == 'not found') { echo 'Nope not in the array'; }
//The Function
    function in_array_r($needle, $haystack, $strict = false) {
        foreach ($haystack as $item) {
            if (($strict ? $item === $needle : $item == $needle) || (is_array($item) && in_array_r($needle, $item, $strict))) {
                return true;
                $found = 'yes';
            }
        }
        $found = 'no';
        return false;
    }

//The Function in use
        //Set the result as a var so you can check it.
  $found = in_array_r($search_pre_order_date,$dates_array) ? 'found' : 'not found';
  
        //If the result is equal to something do something...
        if ($found == 'found') {
    echo 'Yes this item is in the array';
  }elseif ($found == 'not found') {
                echo 'Nope not in the array';
  }

Search

Your Favourite Posts

  • Your favorites will be here.

Latest Content

© Garth Baker 2025 All rights reserved.

Pin It on Pinterest

Garth Baker
en
af
sq
am
ar
hy
az
eu
be
bn
bs
bg
ca
ceb
ny
zh-CN
zh-TW
co
hr
cs
da
nl
en
eo
et
tl
fi
fr
fy
gl
ka
de
el
gu
ht
ha
haw
iw
hi
hmn
hu
is
ig
id
ga
it
ja
jw
kn
kk
km
ko
ku
ky
lo
la
lv
lt
lb
mk
mg
ms
ml
mt
mi
mr
mn
my
ne
no
ps
fa
pl
pt
pa
ro
ru
sm
gd
sr
st
sn
sd
si
sk
sl
so
es
su
sw
sv
tg
ta
te
th
tr
uk
ur
uz
vi
cy
xh
yi
yo
zu
Share This