Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Date format with sup 'st', 'rd', 'nd', 'th' in email delivery

Avatar

Avatar
Validate 10
Level 3
Partha18
Level 3

Likes

19 likes

Total Posts

29 posts

Correct Reply

2 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 10
View profile

Avatar
Validate 10
Level 3
Partha18
Level 3

Likes

19 likes

Total Posts

29 posts

Correct Reply

2 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 10
View profile
Partha18
Level 3

21-08-2019

Hi,

I have created a email delivery where i need to insert date in the format August 21st,2019  (or)  August 21st, 2019.

I have used this script        <%= formatDate(new Date(), "%Bl %D,%4Y") %>

From this, I am able to get August 21,2019. but i want 'st',' nd,' rd', 'th' after the date. How can i get that?

Please help me with this!

Regards,

Partha.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Contributor
MVP
wodnicki
MVP

Likes

926 likes

Total Posts

1,056 posts

Correct Reply

494 solutions
Top badges earned
Contributor
Shape 1
Give Back 100
Give Back 50
Give Back 25
View profile

Avatar
Contributor
MVP
wodnicki
MVP

Likes

926 likes

Total Posts

1,056 posts

Correct Reply

494 solutions
Top badges earned
Contributor
Shape 1
Give Back 100
Give Back 50
Give Back 25
View profile
wodnicki
MVP

21-08-2019

Hi,

Use this:

<%= formatDate(new Date(), '%Bl %D, %4Y').replace(/\d+/, function ($1) {return $1 + (

  $1 == 31 || $1 == 21 || $1 == 1 ? 'st' :

  $1 == 22 || $1 == 2 ? 'nd' :

  $1 == 23 || $1 == 3 ? 'rd' :

  'th'

)}) %>

Thanks,

-Jon

Answers (0)