Last active
December 9, 2017 17:44
-
-
Save amitkhare/c2971d7d5b6c42a524a9e9cfe1cd7ba2 to your computer and use it in GitHub Desktop.
Tutorial available at https://youtu.be/jzYvZkP_vUs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ################################################## | |
// Tutorial available at https://youtu.be/jzYvZkP_vUs | |
// ################################################## | |
// clock start time HH:MM:SS | |
var clockStartAt = "06:00:10"; | |
//Count Up/ Down rate | |
var rate = -1; | |
cStr = clockStartAt.split(":"); | |
// count all seconds for givin time | |
var clockStart = (parseInt(cStr[0]) * 3600) + (parseInt(cStr[1]) * 60) + parseInt(cStr[2]); | |
// calculate clock time from inPoint of the current text Layer. | |
var clockTime = Math.max( clockStart + rate * (time - inPoint), 0); | |
var t = Math.floor(clockTime); | |
var sec = Math.floor( t % 60 ); | |
var min = Math.floor( (t % 3600) / 60 ); | |
var hour = Math.floor( (t % (3600 * 60)) / 3600 ); | |
// to prefix ZERO, we need to create a function | |
function padZero(n){ | |
if (n < 10 ) return "0"+n else return "" + n; | |
} | |
// display time with padZero function | |
padZero(hour) + ":" + padZero(min) + ":" + padZero(sec); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment