Back to Blog Index

How to Use the Time Expression in After Effects

No items found.

What is the Time Expression in After Effects?

The time expression in After Effects returns a composition's current time in seconds. You can write the time expression in After Effects by simply typing the word time;

The values generated by this expression can then be used to drive movement by connecting a property value to the expression.

After Effects counting seconds with the time expression

In the example above I rigged a text layer to preview the value generated by the time expression. As the composition is playing you see the seconds being counted in the composition panel through that rigged text layer. All I did was used a simple time expression to have After Effects generate those values.

time.toFixed(2);

Note: toFixed() limits how many numbers are allowed after the decimal

How Does the Time Expression Work in After Effects?

To help illustrate explain exactly what I mean, I want you to think about time in a new way. Try to think of time as the number it's producing and not as a time counter. When you can start to view time as a number that can be manipulated then you will start getting a better grasp on this expression.

For example, If I double the time expression using multiplication it would read 8 seconds within a 4 second composition time.

time*2;

A faster time readout using the time expression

To further drive it home i'll add the time expression to the rotation property. The rotation property will return 1 degree per 1 second.

Rotating one degree per second

For every second the composition runs the rotation will increase by one degree. But, that example is kinda boring and you may not be able to see much change very well. Let's speed things up a little!

A full rotation every second

Just look at that little line go! In the first example we get 1 degree for every second. So if we want to get a full rotation every second we need to know how many degrees are in 1 full rotation; which is 360 degrees.

time*360;

By multiplying the value time provides by 360 we are asking After Effects to speed up the process exponentially. It now is going to complete a 1 degree move 360 times within one second.

Examples of the Time Expression in After Effects

Now that you've wrapped your head around what time is doing, let's show you some practical examples you can start using in your workflow.

Rotate Multiple Layers

Here is an example of looping rotations at different speeds. Imagine if you had a bunch of gears that needed to rotate, or an astroid field that needed slight rotations for those cold heavy rocks.

I took the time expression and multiplied them by different amounts! As a bonus, I'd like to share a neat trick that I first learned from Parker Young's expression courses on Animoplex.

For rotation, multiply time by 360, which is one full rotation, and then divide it by the number of seconds you would like a full rotation to happen. Here's what that would look like in code:

// One full rotation every 2 seconds
time*(360/2);

Time Travel, Sorta...

One really useful way to harness the time expression is creating delayed movements. We can actually ask After Effects to look forwards and backwards in time. For this I'm going to introduce a new expression valueAtTime();.

The bottom layer is delayed from the top layer

For this example I asked After Effects to look at the x position of another layer, and then told it to delay by half a second. Amazingly, the code is super simple, and by using the index of a layer you can duplicate over and over again with each layer having it's own delaying. Note: The index expression in After Effects pulls a value based on the layer's order in the timeline.

thisComp.layer(index+1).transform.xPosition.valueAtTime(time - .5)

Does that expression seem confusing? Zack Lovatt is a fan of breaking down the various parts of code into common language so it's easier to understand. Here is how he would break down valueAtTime:

var halfASecond = 0.5;
var now = time;
var halfASecondAgo = now - halfASecond;

valueAtTime(halfASecondAgo);

In a nutshell, valueAtTime is an expression that tells After Effects to pull a value from a property (scale, position, slider, etc.) for a declared time.

MAKE IT RAIN!

If you want to try out something fun, I'm handing off a simple project file to you. Inside you'll find a money counting rig tied to time. I've placed a slider effect in there that allows you to increase how fast the money value is increasing! If you'd like to know how I added the dollar sign to the money counter, I've left some notes in my expression.

{{lead-magnet}}

It's Time for More!

I hope you see how awesome the time expression can be. There are a lot of use cases outside of what I went over in this article!

If you want to learn more about using expressions in After Effects we have a ton of other great expression content here on School of Motion. Here are a few of our favorite tutorials:

Also, if you want to master expressions in After Effects, we have the course for you! Check out Expression Session taught by Zack Lovatt & Nol Honig!

EXPLORE ALL COURSES

Dive into real-time 3D with our Unreal Engine beginner's course by Jonathan Winbush. Master importing assets, world-building, animation, and cinematic sequences to create stunning 3D renders in no time! Perfect for motion designers ready to level up.

Explore this Course

Unlock the secrets of character design in this dynamic course! Explore shape language, anatomy rules, and motifs to craft animation-ready characters. Gain drawing tips, hacks, and Procreate mastery (or any drawing app). Ideal for artists seeking to elevate their craft.

Explore this Course

Elevate your freelance motion design career with our guide to client success. Master a repeatable method for finding, contacting, and landing clients. Learn to identify prospects, nurture leads, and develop a thriving freelance philosophy amidst chaos.

Explore this Course

Rev up your editing skills with After Effects! Learn to use it for everyday needs and craft dynamic templates (Mogrts) for smarter teamwork. You'll master creating animated graphics, removing unwanted elements, tracking graphics, and making customizable templates.

Explore this Course

Stand out with Demo Reel Dash! Learn to spotlight your best work and market your unique brand of magic. By the end, you'll have a brand new demo reel and a custom campaign to showcase yourself to an audience aligned with your career goals.

Explore this Course

Illuminate your 3D skills with Lights, Camera, Render! Dive deep into advanced Cinema 4D techniques with David Ariew. Master core cinematography skills, gain valuable assets, and learn tools and best practices to create stunning work that wows clients.

Explore this Course

Master After Effects at your own pace with Jake Bartlett's beginner course. Perfect for video editors, you'll learn to create stylish animated graphics, remove unwanted elements, and track graphics into shots. By the end, you'll be equipped for everyday AE needs and more.

Explore this Course

Revolutionize your Premiere workflow with customizable AE templates! Master creating dynamic Motion Graphics Templates (Mogrts) in After Effects to speed up your team's work. By the end, you'll craft easily-customizable templates for seamless use in Premiere Pro.

Explore this Course
Your download is in your inbox!!!
Check your email (spam, too) for the download link!
Please check the spam folder if you don't see the message within a minute or two. Google likes to hide your downloads, sometimes.
Oops! Something went wrong while submitting the form.

Not sure where to start?

If you’re a beginner, here are some great courses to help you get started:

After Effects Kickstart

Dive into the fundamentals of motion design with our most popular (and recently updated) After Effects course.

LEARN MORE

Photoshop + Illustrator Unleashed

Master the basics of Photoshop and Illustrator and gain invaluable insights in this introductory level course.

LEARN MORE

Design Kickstart

An introduction to the design principles behind all great work.

LEARN MORE

More Advanced?

If you’re a more advanced student looking to up your game, here are some great options:

Animation Bootcamp

Learn the art and principles of creating beautiful movements in Adobe After Effects.

LEARN MORE

Design Bootcamp

Learn to design for motion in this intermediate-level, project-based course.

LEARN MORE

Cinema 4D Basecamp

Learn Cinema 4D from the ground up in this exciting introductory C4D course.

LEARN MORE

Now is the time to learn the skills you need to advance in your motion design career: