Trouble formatting dates in text field

Good morning,

I have the following code I am using inside a text component to display a date from a table that is pulling data from the retool database if it is available:

{{ table4.selectedRow.agreement_date ? 'Agreement Date:   ' + table4.selectedRow.agreement_date : 'Agreement Date: Not Specified'}}

How would I go about changing the format of that date within that code? I have tried several different times, but nothing works.

@tomm here you go

new Date(table4.selectedRow.agreement_date).toLocaleString('en-US', { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: '2-digit', hour12: true })

@Derek_Watts, thank you so much!

1 Like

just offering an alternative:

moment(new Date(table4.selectRow.agreement_date)).format('YYYY-MM-DD HH:mm:ss')

moment(new Date(table4.selectRow.agreement_date)).utc().format('YYYY-MM-DD HH:mm:ss')

moment(new Date(table4.selectRow.agreement_date)).toLocaleString().format('YYYY-MM-DD HH:mm:ss')

Thank you.

1 Like