Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Php countup from a date

<div class="countup" id="countup1">
  <span class="timeel months">00</span>
  <span class="timeel showweeks">00</span>
  <span class="timeel showdays">00</span>
</div>
<script>
// Month, Weeks and days counter
window.onload = function() {
  // Month, Day, Year Hour:Minute:Second, id of element container
  countUpFromTime("Jul 07, 2022 00:00:00", 'countup1'); // !! Change this line !!
};
function countUpFromTime(countFrom, id) {
  countFrom = new Date(countFrom).getTime();
  var now = new Date(),
      countFrom = new Date(countFrom),
      timeDifference = (now - countFrom);
    
  var secondsInADay = 60 * 60 * 1000 * 24,
      secondsInAHour = 60 * 60 * 1000;
    
  	days = Math.floor(timeDifference / (secondsInADay) * 1);
 	 weeks = Math.floor(days / 7);
  	months = Math.floor(weeks / 4)
  	showdays = Math.floor(days - (weeks * 7));
  	showweeks = Math.floor(weeks -(months * 4))
  	years = Math.floor(days / 365);
  if (years > 1){ days = days - (years * 365) }
  	hours = Math.floor((timeDifference % (secondsInADay)) / (secondsInAHour) * 1);
  	mins = Math.floor(((timeDifference % (secondsInADay)) % (secondsInAHour)) / (60 * 1000) * 1);
  	secs = Math.floor((((timeDifference % (secondsInADay)) % (secondsInAHour)) % (60 * 1000)) / 1000 * 1);

  var idEl = document.getElementById(id);
  	idEl.getElementsByClassName('months')[0].innerHTML = months;
  	idEl.getElementsByClassName('showweeks')[0].innerHTML = showweeks;
  	idEl.getElementsByClassName('showdays')[0].innerHTML = showdays;
  
  clearTimeout(countUpFromTime.interval);
  countUpFromTime.interval = setTimeout(function(){ countUpFromTime(countFrom, id); }, 1000);
  </script>
Comment

PREVIOUS NEXT
Code Example
Php :: php get numer of items 
Php :: datetime-local laravel migration data type 
Php :: symmetric decryption in php 
Php :: many posts in the isset 
Php :: laravel command Retrieve a specific option 
Php :: livewire component lost data 
Php :: PHP str_pad — Pad a string to a certain length with another string 
Php :: php code for adding dara 
Php :: laravel Why using additive paramerer in Resource collection raised error 
Php :: php read textarea line by line 
Php :: how to find number between different ranges in php 
Php :: Remove images from the the_content() 
Php :: statamic asset tag 
Php :: WordPress oEmbed Funktion abschalten 
Php :: how to show limited text in laravel on page 
Php :: BelongsToMany relations pivot fields are null in Livewire refresh 
Php :: how to download file in laravel 8 delelete from directry 
Php :: PHP strspn — Finds the length of the initial segment of a string consisting entirely of characters contained within a given mask 
Php :: wp dev tehem support widget 
Php :: laravel required_if fileld has value 
Php :: failed to delete data in mysqli using php 
Php :: Laravel Read multiple file extensions 
Php :: Laravel validation rule for one item which can be email or phone numbe 
Php :: how to clear post array on referesh + not refill when return 
Php :: add tag tpo protfolio? 
Php :: PHPMailer/SMTP.php line 467 
Php :: php registration form and login in same page 
Php :: heroku mysql 
Php :: laravel facade 
Php :: http_build_query 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =