App Connect Data Formatter Support Product Page

Answered

Countdown Timer?

Asked 06 Sep 2017 03:12:38
1
has this question
06 Sep 2017 03:12:38 Brad Lawryk posted:
Is it possible to create a countdown timer?

I can get it to count down how many days or how many hours how many minutes individually. That works great.

But I get "Projected opening in 3 Days, 70 Hours and 4252 Minutes"

I need it broken to be "Projected opening in 3 Days, 22 Hours and 52 Minutes"

Possible somehow?

Replies

Replied 07 Sep 2017 10:13:12
07 Sep 2017 10:13:12 Teodor Kuduschiev replied:
Hi Brad,
Yes that is possible.
I will show this with a static date, but if it comes from a db, it is the same, just replace the date with the database value.

1. Create a datetime component and set its interval to seconds:

2. Days would be:
{{(var1.datetime.secondsUntil("2018-09-14") / 86400).floor()}}

3. Hours:
{{((var1.datetime.secondsUntil("2018-09-14") / 3600) % 24).floor()}}

4. Minutes
 {{((var1.datetime.secondsUntil("2018-09-14") / 60) % 60).floor()}}


Replied 07 Sep 2017 15:29:39
07 Sep 2017 15:29:39 Brad Lawryk replied:
Oh man, I was so close in the things I was trying! Thanks!
Replied 27 Sep 2017 21:55:13
27 Sep 2017 21:55:13 Brad Lawryk replied:
I have the following code and I would like to hide it once the days hit 0. Possible?

<div>
Next Up: 'Next Up: 'The Woman In Black' opens in {{todaysDate.datetime.daysUntil("2017-10-25")}} days!
</div>

Replied 27 Sep 2017 22:08:32
27 Sep 2017 22:08:32 Brad Lawryk replied:
Hahaha, I was way over thinking it ...... was easier than I thought. This works nicely.

<div dmx-show="todaysDate.datetime <= &quot;2017-10-25&quot;">
Next Up: 'The Woman In Black' opens in {{todaysDate.datetime.daysUntil("2017-10-25")}} days!
</div>

Reply to this topic