Skip to main content
Solved

Converting a date to a readable format in a script


Hi,

I am reading a date from a field and want to include it in an email (as part of an automation).

How do I go about converting the date that looks like this ā€œ2021-02-10t11:30:00.000zā€ into something like this - 10/02/2021 11:30am (or similar)?

Thanks!

Best answer by kuovonne

This is more of a JavaScript question than an Airtable question.

You can convert a JavaScript date object to a string using any of the to...String() methods available for date objects. They are documented here. You probably want toLocaleString(). You can specify options to get the exact formatting that you want.

View original
Did this topic help you find an answer to your question?

2 replies

kuovonne
Forum|alt.badge.img+27
  • Brainy
  • 6001 replies
  • Answer
  • February 8, 2021

This is more of a JavaScript question than an Airtable question.

You can convert a JavaScript date object to a string using any of the to...String() methods available for date objects. They are documented here. You probably want toLocaleString(). You can specify options to get the exact formatting that you want.


  • Author
  • Known Participant
  • 12 replies
  • February 8, 2021
kuovonne wrote:

This is more of a JavaScript question than an Airtable question.

You can convert a JavaScript date object to a string using any of the to...String() methods available for date objects. They are documented here. You probably want toLocaleString(). You can specify options to get the exact formatting that you want.


This was helpful thanks! I didnt realise that those options were not available to me because I was trying to use them on a string :slightly_smiling_face:
Thanks!


Reply