Vuejs Countdown Timer Minutes Seconds Example

Vuejs Countdown Timer Minutes Seconds Example

In this Post We Will Explain About is Vuejs Countdown Timer Minutes Seconds Example With Example and Demo.Welcome on infinityknow.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to simple countdown timer using VuejsExample

In this post we will show you Best way to implement Vuejs with bootstrap countdown timer, hear for Vuejs countdown timer minutes secondswith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Simple create vuejs

Make a HTML file and define markup

<div id="liveApp">
  
</div>
<!-- countdown Timer using Vuejs Example-->

  <div class="countdown">
  <!-- countdown Timer Days using Vuejs Example-->
    <div class="live_block">
      <p class="live_digit">{{ livedays | live_twodays }}</p>
      <p class="your_text">liveDays</p>
    </div>
	  <!-- countdown Timer Hours using Vuejs Example-->
    <div class="live_block">
      <p class="live_digit">{{ live_hours | live_twodays }}</p>
      <p class="your_text">live_hours</p>
    </div>
	<!-- countdown Timer Minutes using Vuejs Example-->
    <div class="live_block">
      <p class="live_digit">{{ live_minutes | live_twodays }}</p>
      <p class="your_text">live_minutes</p>
    </div>
	  <!-- countdown Timer Seconds using Vuejs Example-->
    <div class="live_block">
      <p class="live_digit">{{ live_seconds | live_twodays }}</p>
      <p class="your_text">live_seconds</p>
    </div>
  </div>

Make a js file and define scripting

Vue.component('countdown', {
  template: '#countdown-template',
  mounted() {
    window.setInterval(() => {
        this.now = Math.trunc((new Date()).getTime() / 1000);
    },1000);
  },
  props: {
    date: {
      type: String
    }
  },
  data() {
    return {//return functions
      now: Math.trunc((new Date()).getTime() / 1000)
    }
  },
  computed: {
    live_dateInMilliseconds() {
	//return functions
      return Math.trunc(Date.parse(this.date) / 1000)
    },
    live_seconds() {
	//return seconds functions
      return (this.live_dateInMilliseconds - this.now) % 60;
    },
    live_minutes() {
      return Math.trunc((this.live_dateInMilliseconds - this.now) / 60) % 60;
    },
    live_hours() {
      return Math.trunc((this.live_dateInMilliseconds - this.now) / 60 / 60) % 24;
    },
    livedays() {
      return Math.trunc((this.live_dateInMilliseconds - this.now) / 60 / 60 / 24);
    }
  }
});

Vue.filter('live_twodays', (get_val) => {
  if (get_val < 0) {
    return '00';
  }
  if (get_val.toString().length <= 1) {
    return `0${get_val}`;
  }
  return get_val;
});


var liveApp = new Vue({
  el: '#liveApp'
});

Example

READ :  Top 10 Advanced Angular 6 Interview Questions Answers

I hope you have Got What is Vuejs Countdown Timer Minutes Seconds Example And how it works.I would Like to have FeadBack From My Blog(infinityknow.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(infinityknow.com) Are Most Always Welcome.

Leave a Reply

Your email address will not be published. Required fields are marked *