HDTuto.com

Vue Js Get Current Date and Time Example



In this artical, i will let you know how to get current date and time in vue js app. we can easily get current date and time using javascript Date(). you can also display current date with any format like dd-mm-yyyy etc.

You can see bellow example that will help you to getting current date and current time in vue.js.

Bellow i gave you very simple example so you can understand how to display current date and time in vue app.

Example:

<!DOCTYPE html>

<html>

<head>

<title>How to get current date time in vue js? - ItSolutionStuff.com</title>

<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

</head>

<body>

<div id="app">

{{ message }}

</div>

</body>

<script type="text/javascript">

new Vue({

el: '#app',

data: {

message:"Welcome, Please Wait...."

},

methods:{

callFunction: function () {

var currentDate = new Date();

console.log(currentDate);

var currentDateWithFormat = new Date().toJSON().slice(0,10).replace(/-/g,'/');

console.log(currentDateWithFormat);

}

},

mounted () {

this.callFunction()

}

});

</script>

</html>

It will help you...




July 21, 2019 | Category : Vue.js
Related Posts



Blog Search