0

I have a variable in my program that stores the date in the form of 2018-04-21. Now, how do I change the value into something like 21st April, 2018?

I need something like:

var date = stringifyTheDate(actual_date);

What should I include in the stringifyTheDate function to do that?

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135

1 Answers1

0

If you are using Moment.js this how you do it.

console.log(moment("2018-04-21").format("DD MMMM YYYY")); //prints 21 April, 2018

MomentJs is widely used library for date and time, if you are not using it then this is how you add it

<script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.2.1/moment.min.js"></script>
UsamaAmjad
  • 4,175
  • 3
  • 28
  • 35