I am using React, and receiving the following data in Typescript. I want to display date in this format. mm/dd/yyyy,
export type Payment = {
paymentId: number;
paymentDate: Date;
}
Data looks like this example: 2022-02-11T20:00:00.000Z
I cannot do this, as it gives error: date .toISOString is not a function
{payment.paymentDate.toISOString().substring(0, 10)}
I have to reconvert into Date again to show. All my dates are valid in checking data, so why do I need to reconvert again?
{new Date(payment.paymentDate).toISOString().substring(0, 10)}