date?
- lloydalvarez
- Enhancement master
- Posts: 460
- Joined: June 17th, 2004, 9:27 am
- Location: New York City, NY
- Contact:
is there a way to get the current date using expressions?
-
- Posts: 320
- Joined: June 26th, 2004, 10:01 am
- Location: Folsom, CA
- Contact:
I don't think so Lloyd. You can use the Date methods to format and manipulate a date (that you supply), but you can't get at the system date/time.
Dan
Dan
hello,
could you (Dan) briefly explain how the Date(number) method works in expressions ?
if I write this expression for source text
I get the current date and time and it updates as the comp time augments.
if I replace '0' by any other number (10000000 for example), it doesn't seem to change anything.
simply a curiosity...thanks.
could you (Dan) briefly explain how the Date(number) method works in expressions ?
if I write this expression for source text
Code: Select all
Date(0);
if I replace '0' by any other number (10000000 for example), it doesn't seem to change anything.
simply a curiosity...thanks.
-
- Posts: 320
- Joined: June 26th, 2004, 10:01 am
- Location: Folsom, CA
- Contact:
Wow - I didn't know that would work (sorry Lloyd). I've got to run, but I'll play around with this later. Thanks!
Dan
Dan
-
- Posts: 320
- Joined: June 26th, 2004, 10:01 am
- Location: Folsom, CA
- Contact:
This is most bizarre. According to my JavaScript reference, there is a Date() function (which returns a string) and a Date() constructor that returns a date object (with which you can use the Date() methods, like getDay(), getFullYear(), etc) Using either of these with no parameters is supposed to get you the current (system) date and time. But if you try to use the function:
myDate = Date();
or the constructor:
myDate = new Date();
You will get this error:
"Can't use Date() in After Effects to get current date. You can use the constructor with arguments."
Which implies that AE does not want you to get the system date/time. There's probably a good reason for that, because I would think you'd run into issues with cached frames not matching up with unrendered frames. My guess is that Date(0) as a function call somehow snuck under the radar.
The time part doesn't appear to be very useful because of the discontinuities. But you could get the date (which should be OK as long as you don't cross midnight) like this:
parts = Date(0).split(" ");
parts[0] + " " + parts[1] + " " + parts[2] + " " + parts[3]
Note that you'd use the string method split() and not any of the Date() methods because Date() as a function returns a string.
So, I think you may have discovered an unintentional feature.
Dan
myDate = Date();
or the constructor:
myDate = new Date();
You will get this error:
"Can't use Date() in After Effects to get current date. You can use the constructor with arguments."
Which implies that AE does not want you to get the system date/time. There's probably a good reason for that, because I would think you'd run into issues with cached frames not matching up with unrendered frames. My guess is that Date(0) as a function call somehow snuck under the radar.
The time part doesn't appear to be very useful because of the discontinuities. But you could get the date (which should be OK as long as you don't cross midnight) like this:
parts = Date(0).split(" ");
parts[0] + " " + parts[1] + " " + parts[2] + " " + parts[3]
Note that you'd use the string method split() and not any of the Date() methods because Date() as a function returns a string.
So, I think you may have discovered an unintentional feature.

Dan
- lloydalvarez
- Enhancement master
- Posts: 460
- Joined: June 17th, 2004, 9:27 am
- Location: New York City, NY
- Contact:
aha! i was going to tell you about the weird error that AE gives, but i figured you'd see it yourself. thanks for figuring it out, i am sure it would have taken me much longer!
lloyd
lloyd
I also got the same error... that's why I tried to specify an argument (an integer in my case).
I've made my own experiments too ... just for fun
I put this sourceText expression that mainly consists in a while loop and call the Date() function before/after the loop to get the 'running time'.
kind of "benchmark expression" 
I've made my own experiments too ... just for fun
I put this sourceText expression that mainly consists in a while loop and call the Date() function before/after the loop to get the 'running time'.
Code: Select all
i = 0; imax = 8000000;
dateStart = Date(0);
while (i < imax) i++;
dateEnd = Date(1);
dateStart +"\r" + dateEnd;

so we can get the current date (which answers part of my question which i just posted on the cow).
but then... how to format it? i want my date to appear in all caps, and there seems to be no way to do this.
would anyone happen to have solution? i'm stumped.
once i can format it according to my every whim, it makes the task of creating daily slates so much easier.
but then... how to format it? i want my date to appear in all caps, and there seems to be no way to do this.
would anyone happen to have solution? i'm stumped.
once i can format it according to my every whim, it makes the task of creating daily slates so much easier.

- lloydalvarez
- Enhancement master
- Posts: 460
- Joined: June 17th, 2004, 9:27 am
- Location: New York City, NY
- Contact:
ScottG wrote: but then... how to format it? i want my date to appear in all caps, and there seems to be no way to do this.
would anyone happen to have solution? i'm stumped.
Code: Select all
parts = Date(0).toUpperCase().split(" ");
parts[0] + " " + parts[1] + " " + parts[2] + " " + parts[3]