Hi to all,How to bind the date from GET API in datepicker in react js. In DB date format is '2021-07-09 00:00:00'. In UI date picker Format 'mm-dd-yyyy' . How to bind the date in datepicker. Please sahre your Idea.
Thankong You.
Hi to all,How to bind the date from GET API in datepicker in react js. In DB date format is '2021-07-09 00:00:00'. In UI date picker Format 'mm-dd-yyyy' . How to bind the date in datepicker. Please sahre your Idea.
Thankong You.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vaibhav ChauhanRank #963 · 2.1K reputationPosted Jul 9, 2021, 9:57 AM EDT
You can import moment.js package to format your date
This is how you can install:
Using it in code:
const moment = require('moment'); const m = moment(new Date('2021/07/09 00:00:00')); console.log(m.format('mm-dd-yyyy'));Reference:
https://thecodebarbarian.com/formatting-javascript-dates-with-moment-js.html