I have a date displayed in HTML. The date is currently displayed as 2012-03-12
. So now, I want to display this date as words i.e it should be displayed as 12 March 2012
. Below is the HTML code I used.
<tr>
<th>Date of Birth: </th>
<td>{{dob}}</td>
</tr>
Here, dob
contains the value that has to be converted to words. How can I do this?
Select all of the dates you want to convert and press Ctrl+C to copy them. Open Notepad or any other text editor, and paste the copied dates there. Notepad automatically converts the dates to the text format. Press Ctrl+A to select all text strings, and then Ctrl+C to copy them.
To set and get the input type date in dd-mm-yyyy format we will use <input> type attribute. The <input> type attribute is used to define a date picker or control field. In this attribute, you can set the range from which day-month-year to which day-month-year date can be selected from.
var words = toWords(num); To get a number converted to words you just need to call the function passing it the number you want to convert and the corresponding words will be returned.
You can use the as. Date( ) function to convert character data to dates. The format is as. Date(x, "format"), where x is the character data and format gives the appropriate format.
Absolutely with the wonderful MomentJS.
dob = moment(dob).format('DD MMMM YYYY');
If your date is an instance of Date
then you can try something like this
var dob = new Date('3/12/2012');
var dobArr = dob.toDateString().split(' ');
var dobFormat = dobArr[2] + ' ' + dobArr[1] + ' ' + dobArr[3];
This would make dobFormat
12 Mar 2012
(if you want it to say March
couple this with what Rhyono has suggested).
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