Reputation: 8240
I want to get following date format (by JavaScript only) - March 3, 2020
var date = new Date();
console.log(date);
Currently I am getting in "2020-05-11T10:08:43.322Z" format. Kindly, help!
Upvotes: 0
Views: 558
Reputation: 2319
You can use moment.js
let date = moment().format('MMMM DD, YYYY');
console.log(date)
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.19.1/moment.min.js" integrity="sha256-zG8v+NWiZxmjNi+CvUYnZwKtHzFtdO8cAKUIdB8+U9I=" crossorigin="anonymous"></script>
Upvotes: 1
Reputation: 20669
You can check Date.prototype.toLocaleString for more information
var date = new Date();
console.log(date.toLocaleString('en-US', {month: 'long', day: 'numeric', year: 'numeric'}));
Upvotes: 4