date with month name format validation
Get date with month name
export const dateWithMonthName = (da) => {
let date = da
if (date !== null && date !== "" && date !== undefined) {
date = new Date(da)
const dateTimeFormat = new Intl.DateTimeFormat('en', { year: 'numeric', month: 'long', day: '2-digit' })
const [{ value: month }, , { value: day }, , { value: year }] = dateTimeFormat.formatToParts(date)
return `${day} ${month} ${year}`
} else {
return ""
}
};
Comments
Post a Comment