Reputation: 149
The date is sent from backend in this format:
"2022-01-01T00:00:00.00000"
How to display date without hours/minutes/seconds like this:
2022-01-01?
On my .tsx component I have InputDatepicker:
<InputDatepicker
label="Training date"
value={trainingData?.trainingDate || ''}
/>
Upvotes: 1
Views: 212
Reputation: 687
Simple
new Date('2022-01-01T00:00:00.00000').toLocaleDateString('en-CA');
Upvotes: 1
Reputation: 77045
You can get the first element of the result of split, like this:
console.log("2022-01-01T00:00:00.00000".split('T')[0]);
Upvotes: 3