DEV Community

Ujjaval
Ujjaval

Posted on • Edited on

I need to get user system's local date-time format to display date-time using react-datepicker

In a react application, we need to show date-time similar to the system locale date-time format (OS specific date-time format).
I am using react-datepicker package but it requires date-time format to show the formatted date on the input and i am unable to get user systemโ€™s local date format. (Refer: https://reactdatepicker.com)


<DatePicker
selected={startDate}
onChange={(date) => setStartDate(date)}
// Need help on providing dateFormat dynamically - as per User's System Date Time Format
dateFormat="dd-MM-yyyy" // dateFormat="MM/dd/yyyy"
/>

Top comments (0)