Forums › Adobe After Effects Expressions › Timezone variable Expression
-
Timezone variable Expression
-
David Storr
June 9, 2022 at 12:08 pmHi,
I’m currently trying to build a channel kit and have only have fairly basic knowledge of expressions. I saw an old post by Filip Vandueren which looked perfect but the expression appears to be incomplete & the link no longer works. https://creativecow.net/forums/thread/expression-to-create-different-times-for-different/
https://www.vandueren.be/forumstuff/expressions/timezones.aep
If anyone has anything similar to generate a +/- x no of hours variable return from a single time input please let me know. ie: for 12:00 input a 13:00 return, which flips to 00:00 for a 23:00 input etc. Thanks!
David
Expression to create different times for different countries based on GMT
-
Filip Vandueren
June 14, 2022 at 11:57 amLinks have a funny way of doing that after 15 years 🙂
The basics could be something like this:
originalTime = thisComp.layer("time").text.sourceText.value; // get a time as a string
timeComponents = originalTime.split(":"); // convert it to an array [hourString, minuteString]
d = new Date(0);
d.setHours(parseInt(timeComponents[0]));
d.setMinutes(parseInt(timeComponents[1]));
timeOffset = 1; // 1 hour later
d2 = new Date(d.getTime()+timeOffset*3600000);
offsetTime = d2.toLocaleTimeString([], {hour: '2-digit', minute: '2-digit'});
Log in to reply.