Countdown timer

To be honost I did not know this componant existed and had to be added :scream:

Did add it now:

But still not the countdown.

But you should assign its value as a value you compare to the database value. Just check my explanation in the dmxzone topic you said you followed. Check my code example as well.

Thanks Teodor. I understand the examples better now, except for the minutes, I need it to remain without decimals. Any pointers there: https://askbob.co.za/bids.php?id=41

48

Have you added .floor() to the minutes as per my example?

This is how my code looks now:

{{(var1.datetime.hoursUntil(serverconnect_bids.data.tomorrow)).floor()}} HOURS
{{((var1.datetime.secondsUntil(serverconnect_bids.data.tomorrow)) / 60) % 60).floor()}} MIN
{{(var1.datetime.secondsUntil(serverconnect_bids.data.tomorrow)) % 60).floor()}} SECONDS

In comparing the code that works and code that doesn’t work it appears you have an extra ‘(’ near the beginning of line two?

Thanks @brad, removed it, but still getting the minutes in real time decimals…

The minutes code is wrong and was wrong before also.
It should be:

{{(((var1.datetime.secondsUntil(serverconnect_bids.data.tomorrow)) / 60) % 60).floor()}}

Please be careful and always make sure the number of open brackets is the same as the number of close brackets :slight_smile:

2 Likes

Awesome! Thanks @Teodor!

Hi @Teodor - I’m implementing this. I’m using the following code:

{{var1.datetime.timeUntil(end_date, 'true')}}

This works great, but has an output of: hours, minutes and seconds e.g.:

240:51:52

If I try to format it, it fails and won’t render at all.

{{var1.datetime.timeUntil(end_date, 'true'.formatDate('dd-MM-yyyy HH:mm:ss'))}}

If I try using the structure of your code above e.g.

{{(((var1.datetime.timeUntil(end_date, 'true')) / 60) % 60).floor()}}

I just get NaN indicating I have something wrong here.

I have tried combining multiple formatters to get the desired output e.g.

{{(((var1.datetime.secondsUntil(end_date))/ 86400) % 60).floor()}}d {{(((var1.datetime.secondsUntil(end_date))/ 3600) % 24).floor()}}m {{(((var1.datetime.secondsUntil(end_date)) / 60) % 60).floor()}}s left

This works - but then the counter does not count down live for some reason.

This is the output I’d like to get:
22d 54m 45s left

Any help appreciated.

Well, most probably your datetime variable’s interval is not set to seconds

I have multiple test cases on the same page and those count down per second (as the date time module is set to seconds intervals). It’s just these formatted ones that aren’t counting down live

I don’t see a reason why would they not count down “live” if the datetime component used is set to seconds.

The first one counts down live - the others don’t. I can’t provide any more insight without questions / guidance.

Thanks for your help.

If anyone else has any ideas that would be appreciated.

Can you explain this more detailed? What is the “first one”? What are the others?

I’m referring to my initial post. You can see the first line of code - this counts down fine but is not in the desired format. The others are trial error that end in the desired format but without the live count.

This doesn’t count/show seconds … this counts the minutes. That’s why it doesn’t look like it’s counting. You need to wait like 60 seconds to see it counts.

For seconds you need to also add:

{{(var1.datetime.secondsUntil(end_date)) % 60).floor()}}
1 Like

A list of the different parts up to years:

{{(((var1.datetime.secondsUntil(end_date)) / 31536000)).floor()}}y
{{(((var1.datetime.secondsUntil(end_date))/ 86400)%365).floor()}}d 
{{(((var1.datetime.secondsUntil(end_date)/3600)%24)).floor()}}h 
{{(((var1.datetime.secondsUntil(end_date)/60)%60)).floor()}}m 
{{(((var1.datetime.secondsUntil(end_date)%60))).floor()}}s left

(doesn’t take into account leap years)

2 Likes

Got it! That’s what’s missing then! @Teodorand @bpj I’ll try those thank you!

Thanks @Teodor and @bpj - this resolved it perfectly, thank you both. Much appreciated.

1 Like