Answers for "react component date format"

0

react date format

npm install moment --save
Posted by: Guest on December-08-2020
0

how to trim dates in react

const dateFromData= "06/15/1990" //string type
    const formatDate = (dateString: string) => {
    const options: Intl.DateTimeFormatOptions = { //Typescript ways of adding the type
      year: "numeric",
      month: "long",
      day: "numeric",
    };
      return new Date(dateString).toLocaleDateString([], options);
    };
    console.log(formatDate(dateFromData)); // output will be: June 15, 1990
Posted by: Guest on December-29-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language