Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display date as mm/dd/yyyy without time in React.js

Tags:

html

date

reactjs

I can't get my date to display without the time in an HTML table. This is my code.

<td input type={Date}>{call.date}</td>

The date gets entered by a Date Picker as mm/dd/yyyy but us displayed like this 2019-09-25T00:00:00

like image 867
mszp Avatar asked Sep 18 '25 15:09

mszp


1 Answers

a JS date will always contain the time data even if you didn't provide the time, for the display of the datepicker depends on the datepicker settings/configurations. or you can handle it manually on your side too.

if call.date is a string and contains ISO Date string, then you can do this to display date without time:

<td input type={Date}>{call.date.substring(0, 10)}</td>

or other ways:

// Parse into JS date object
const date = new Date(call.date)
...
<td input type={Date}>{date.toISOString().substring(0, 10)}</td>
like image 165
Jee Mok Avatar answered Sep 21 '25 07:09

Jee Mok