JSFiddle - React, Tailwind, and code Playground

by ruhul105

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.4/moment.min.js"></script>

JavaScript

const data = [
    {
        "first_name": "Ruhul",
        "last_name": "Amin",
        "phone": "015204458173",
        "job_title": "dsda",
        "percentage_shareholding": "32",
        "ssn": "231`3",
        "address": {
            "street": "Rajshahi",
            "city": "Dhaka",
            "state": "",
            "zip": "6530",
            "country": "US"
        },
        "is_applicant": false,
        "date_of_birth": "1988-11-10T18:00:00.000Z"
    },
    {
        "first_name": "John",
        "last_name": "Smith",
        "phone": "01722262414",
        "job_title": "CTO",
        "percentage_shareholding": "54",
        "ssn": "3312121",
        "address": {
            "street": "Vill: DakshinWora; Post: Khajur; Thana: Mohadebpur;",
            "city": "Mohadebpur",
            "state": "CA",
            "zip": "6530",
            "country": "US"
        },
        "is_applicant": false,
        "date_of_birth": "2022-12-20T18:00:00.000Z"
    }
]

 const formatDateOfBirth = data.reduce(function (a, b) {
      const formattedItem = {
        ...b,
        ['date_of_birth']: moment(b.date_of_birth).format('YYYY-MM-DD'),
      };
      a.push(formattedItem);
      return a;
    }, []);
    
    console.log('formattedDateOfBirth:', formatDateOfBirth)