UNPKG

numbers-words

Version:

numbers-words is a useful package when you are working with numbers. It can converts numbers to words, format numbers and more in the upcoming versions!

24 lines (16 loc) 582 B
const toWords = require("./toWords.js"); const toOrdinalWord = require("./toOrdinalWord.js"); function toWordsDate(date) { const datet = new Date(date); const monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; const month = monthNames[datet.getMonth()]; const day = datet.getDate(); const year = datet.getFullYear(); const dayWord = toOrdinalWord(day); const yearWord = toWords(year); return `${month} ${dayWord}, ${yearWord}`; } module.exports = toWordsDate;