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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

AWS Security LIVE!

Hosted by security experts, AWS Security LIVE! showcases AWS Partners tackling real-world security challenges. Join live and get your security questions answered.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️