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

ujjaval

Ujjaval

Posted on December 28, 2023

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"
/>

💖 💪 🙅 🚩
ujjaval
Ujjaval

Posted on December 28, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related