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 [{ valuemonth }, , { valueday }, , { valueyear }] = dateTimeFormat.formatToParts(date)
    return `${day} ${month} ${year}`
  } else {
    return ""
  }
};

 https://freecodesmasters.blogspot.com/2020/09/date-with-month-name-format-validation.html

Comments

Popular posts from this blog

Image Preview Before upload image into ReactJs

Format mobile number to this format "(845) 963-2545" #mobileFormat