Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

I'm trying to create a digital clock that updates in real time using expressions.

New Here ,
Feb 15, 2024 Feb 15, 2024

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:example.jpgexpand image

TOPICS
Expressions , How to , Import and export
376
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Feb 15, 2024 Feb 15, 2024

To display the current LONG DATE, you can use Numbers Effects

You can add a point control (hh:mm) effect to set the start time

 

Add this expression and set the offset value:

offset = 0;
hh = Math.floor(thisComp.layer("LONG DATE").effect("hh:mm")(1)[0]) + ((offset % 24) + 24) % 24;
mm = Math.floor(thisComp.layer("LONG DATE").effect("hh:mm")(1)[1]);
(Math.floor(hh + (time + mm * 60) / 3600) % 24).toString().padStart(2, 0) +
  ':' +
  (Math.floor(mm + time / 60) % 60).toString().padStart(2, 0) +
  '\rPACIFIC'

 

screenshot.pngexpand image

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 16, 2024 Feb 16, 2024

Take a look at Dan Ebberts' Universal Up-down-Clock.

 

All your code does is grab the current time when you stop editing the expression and make it live. You have no provision to add more time based on the frame count or the current time. To keep things simple you would have to enter the starting values by hand. You might be able to generate a counter that records the start time of a render, but you can't make that kind of counter live in the video.

 

What is the design goal? There is no way to make a rendered video show the current time because the frames are rendered. If you need to display the current time when a video is being played, you will have to add an overlay to the media player. That requires some scripting on a web page or utilizing a media player with that capability. 

 

If you just want a rendered time and date counter, start with Dan's code on HTTP://mostiionscript.com.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 16, 2024 Feb 16, 2024
LATEST

This will never work. AE doesn't dynamically refresh the date() functions. It only does so when the expression is edited or the project opened. That's why your stuff doesn't render via AME, either. As explained, you need to re-create it all from scratch with animated sliders or based on AE's native time() function for it to even produce a usable result.

 

Mylenium

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines