import React, { useState } from "react"; import { formatDateTime } from "../../../constant/Utils"; import { useTranslation } from "react-i18next"; const DateFormatSelector = (props) => { const { t } = useTranslation(); const date = new Date(); const [selectedFormat, setSelectedFormat] = useState(props.dateFormat); const [is12Hour, setIs12Hour] = useState(props?.is12HourTime); const dateFormats = [ "MM/DD/YYYY", "MMMM DD, YYYY", "DD MMMM, YYYY", "DD-MM-YYYY", "DD MMM, YYYY", "YYYY-MM-DD", "MM-DD-YYYY", "MM.DD.YYYY", "MMM DD, YYYY" ]; // Handle format change const handleFormatChange = (event) => { setSelectedFormat(event.target.value); props.setDateFormat && props.setDateFormat(event.target.value); }; const handleHrInput = () => { setIs12Hour(!is12Hour); props.setIs12HourTime && props.setIs12HourTime(!is12Hour); }; return (
{formatDateTime(date, selectedFormat, props?.timezone, is12Hour)}