Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use DateField with timestamp value in react-admin?

Tags:

react-admin

I have timestamp(String) value. Can I use DateField with timestamp?

<DateField source="createdAt" showTime /> // createAt: timeStamp(String)
like image 435
L. beom Avatar asked Jan 28 '26 21:01

L. beom


1 Answers

Cast your timestamp to an integer, e.g. using a custom component:

const DateFieldForTimestamp = props => {
    const recordWithTimestampAsInteger = {
        [props.source]: parseInt(props.record[props.source], 10)
    };
    return <DataField {...props} record={recordWithTimestampAsInteger} />
}
like image 62
François Zaninotto Avatar answered Feb 01 '26 09:02

François Zaninotto



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!