Help

Converting a date to a readable format in a script

Topic Labels: Scripting extentions
Solved
Jump to Solution
4095 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Jac_Evans
6 - Interface Innovator
6 - Interface Innovator

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!

1 Solution

Accepted Solutions
kuovonne
18 - Pluto
18 - Pluto

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.

See Solution in Thread

2 Replies 2
kuovonne
18 - Pluto
18 - Pluto

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!