How can I include plain text in a date format string?

Viewed 111

I am using <Statistic.Countdown /> from Ant design to display the dates.

I'd like to achieve a format like: "2 years, 4 months, 5 days HH:mm:ss"

I have format={"M months D HH:mm:ss"}, but of course this interprets the "m" in months as the symbol for minutes, and so on: 3 42onth36 25 17:42:36.

How could I achieve "3 months 25 days 17:42:36"?

Edit: Thanks to Samathingamajig I got this working. Now I'm wondering, how can I insert a newline? I tried the following, but of course the second line will just show the full countdown in HH:mm:ss

  <Countdown title="Countdown" value={date} format={"M [months] D [days]"}/>
  <Countdown title="" value={date} format={"HH:mm:ss"}/>

I've tried using \n and <br>, both plain and enclosed in square brackets, to no effect.

2 Answers

Try with single quotes like:

format={"M 'months' D HH:mm:ss"}

Related