I'm trying to create a digital clock that updates in real time using expressions.
I think I'm close to making this work but could use some help if anybody has experience with this. I got the expressions using chatgpt and when I paste them into the source text they initally show the current time correctly in the preview. I export out of Media Encoder I've tried several formats and players but it's not working. It just stays on the same time - the whole time. A couple early versions I tried was flashing between two numbers in the minutes field.
For reference here is the script for one of the time zones:
// Define the time zone offset for Pacific Time (UTC-8)
var timeZoneOffset = -8;
// Get the current UTC time
var utcTime = new Date();
var utcHours = utcTime.getUTCHours();
var utcMinutes = utcTime.getUTCMinutes();
// Convert UTC time to Pacific Time
var pacificHours = utcHours + timeZoneOffset;
var pacificMinutes = utcMinutes;
// Adjust for negative hours (e.g., crossing midnight)
if (pacificHours < 0) {
pacificHours += 24;
}
// Format hours and minutes
pacificHours = (pacificHours < 10) ? '0' + pacificHours : pacificHours;
pacificMinutes = (pacificMinutes < 10) ? '0' + pacificMinutes : pacificMinutes;
// Return formatted time
pacificHours + ':' + pacificMinutes;
I also have todays date and 4 time zones in this which when finished will just be 1 hour long and loop AND hopefully refresh with the current time. See screenshot below:
