ItSolutionStuff.com

How to Get Current Date and Time in Vue JS?

By Hardik Savani • July 5, 2023
Vue.JS

Do you want to get current date in vue js app. If yes then i will help you to getting current date and time in vue js app. if you know to get current date in javascript or jquery then you can get same way using Date Class. we can also display current date with yyyy-mm-dd format.

it is a very simple to get current date time in vue js because we can get it using Date(). Date() will provide full date and time with timezone. so you can also make better format like yyyy-mm-dd.

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>

I hope it can help you....

Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Vue JS Call a Function On Load Example

Read Now →

Laravel Vue Datatables Component Example

Read Now →

How to use datepicker in vuejs?

Read Now →

Vue JS MultiSelect Dropdown Example

Read Now →

Vue Js Sweetalert Modal Notification Example

Read Now →

Vue Axios Post Request Example Tutorial

Read Now →

How to Change Date Format using Moment in Vue JS?

Read Now →

Vue JS Toggle Switch Button Example

Read Now →

Vue Toastr Notifications Example Code

Read Now →

How to Replace String in Vue JS?

Read Now →

Laravel Vue JS File Upload Using Vue-dropzone Example

Read Now →

Laravel Vue JS Infinite Scroll Example with Demo

Read Now →

Laravel Vue JS Pagination Example with Demo

Read Now →