Getting a current Year in Vue app

Getting a current Year in Vue app

In this post we will give you information about Getting a current Year in Vue app. Hear we will give you detail about Getting a current Year in Vue appAnd how to use it also give you demo for it if it is necessary.

we will learn about how to get a current year in the vue app.

Getting the current year

We can get the current year in vue by calling a getFullYear() method on a new Date() constructor.

The getFullYear() method returns the year according to the user local time in four-digit(2020) format.

In this below example, we are rendering a current year in the footer component of our vue app.

Footer.vue
<template>  <div id="app">    <footer>      <p>CopyRight - {{new Date().getFullYear()}}</p>    </footer>  </div></template>

Instead of directly adding new Date().getFullYear() method to the template, we can also store it in the vue data property like this.

Footer.vue
<template>  <div id="app">    <footer>      <p>CopyRight - {{currentYear}}</p>    </footer>  </div></template><script>export default {  data() {    return {      currentYear: new Date().getFullYear(), // 2020    };  }};</script>

Hope this code and post will helped you for implement Getting a current Year in Vue app. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US