I want to change the javascript time display.

Asked 1 years ago, Updated 1 years ago, 63 views

I am currently writing the code with react.
I am displaying the data in json format that I received from axios.
I'd like to display this image until 2020-03-18, but I don't know how to display it because json's information itself includes time.I tried javascript getmonth, but it didn't show well, so could someone tell me?

<TableCell>Date</TableCell>      
{
    Payments.map(transaction,index)=>(
        <TableCell> {transaction.CreatedAt}</TableCell>
}

View Date Here

javascript json reactjs axios

2022-09-30 18:12

1 Answers

Why don't you convert it to a Date instance and then string it to the format you want?

const date=new Date('2020-03-18T06:10:17Z');
console.log(`${date.getFullYear()}-${date.getMonth()+1}-${date.getDate()}}`);//2020-3-18


2022-09-30 18:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.