How do I display current year in footer page like ©year
in vue.js
Ex : ©2021 ©2020
following is the pure JavaScript version.
document.write(new Date().getFullYear())
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.
Vue is a free and open source project released under the MIT License.
Add a script tag inside your Vue component template. Just add the script into the component template. But don't forget to add, type="application/javascript" to the script tag otherwise it will show an error during the build.
Why not just use text interpolation?
new Vue({
el: '#app',
});
<script src="https://unpkg.com/vue/dist/vue.min.js"></script>
<div id="app">
©{{ new Date().getFullYear() }}
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With