How to change the JS code in a weblayer countdown to show more than 100 hours

You may face a problem when weblayer the countdown timer is showing 100+ hours, and the countdown module is able to display only two characters up to 99 hours maximum. In the following image, the hour's field should display 198 hours, but it is only displaying 98 because the first character was stripped by default.

This issue can be fixed by altering weblayer’sJavaScript code. You only need to allow 3 characters in the weblayer hour's field.

You must go inside your JavaScript code and find the initializeClock function. In that function, there is a line that sets hoursSpan inner HTML, you need to modify a parameter passed to slice method.

In order to show 3 digits in the hour's field, you have to amend the slice(-2) to slice(-3). With this, you basically set up the limit of the characters in the targeted hour's field, and the output of the countdown banner wouldn't be misleading, but it will be correct if it shows values over 99.

👍

Did this article help you?

Please provide your feedback. We would like to know if our help center is effective in solving your queries. You can also leave comments and suggestions on how we can make our help articles better. You can also suggest topics you’d like us to cover.