-
Adding 00s to DAYS in a counter timer using format YEARS:DAYS:HOURS:MINUTES:SECONDS
Hi everyone.
Long time lurker. First time poster ☺
Usually I can hash together an expression using what I can find online (mostly from this website tbh) but I’m having trouble with this particular one.I’m making a counter using the expression below. The time format I’m using is YEARS:DAYS:HOURS:MINUTES:SECONDS
As you can see I’m using a function to add 0 to n if n is less than 10.
This works fine for the 2 digit numbers (YEARS, HOURS, MINUTES, SECONDS) but not with the 3 digit number (DAYS).I would like to achieve YY:DDD:HH:MM:SS
For example 01:009:23:59:59. Where the DAYS always has 3 digits whether its 001, 999 or anything in between.Thank you kindly for your help. I hope in the future, as I grow in confidence using expressions, I’ll be able to help someone else here in return.
Much love and respect.Simon.
slider = effect("Point Control")("Point")[0]sec = Math.floor(slider)%60;
min = Math.floor(slider/60)%60;
hour = Math.floor(slider/3600)%24;
days = Math.floor(slider/86400)%365;
years = Math.floor(slider/31536000);function addZero(n) {
if (n < 10) return "0" + n else return n;
}addZero(years) + ":" + addZero(days) + ":" + addZero(hour) + ":" + addZero(min) + ":" + addZero(sec)