Copy link to clipboard
Copied
For the life of me, I can't find any Expressions that deal with displaying the current system time using the source text property.
What's a good way to get "04:53 PM"? (assuming the time is really 4:53PM)
Alternatively, using Dan's universal counting clock, he uses a variable named "clockStart =". What would I use to return the current system time?
Yes, that's correct.
Dan
Copy link to clipboard
Copied
I haven't tested this thoroughly, but it should get you close:
D = new Date(Date(0));
h = D.getHours();
m = D.getMinutes();
suffix = h >= 12 ? "PM" : "AM";
if (h > 12) h -= 12;
h = "" + h;
if (h.length < 2) h = "0" + h;
m = "" + m;
if (m.length < 2) m = "0" + m;
h + ":" + m +" " + suffix
Dan
Copy link to clipboard
Copied
Thanks Dan! Looks like it works perfectly! (as usual)
So I could use D.getHours, D.getMinutes, and (I'm assuming) D.getSeconds to build a running military clock with seconds?
Copy link to clipboard
Copied
Sure:
D = new Date(Date(0));
h = D.getHours();
m = D.getMinutes();
s = D.getSeconds();
h = "" + h;
if (h.length < 2) h = "0" + h;
m = "" + m;
if (m.length < 2) m = "0" + m;
s = "" + s;
if (s.length < 2) s = "0" + s;
h + ":" + m + ":" + s
Dan
Copy link to clipboard
Copied
so h = "" + h turns a number value into a string? And h.length is the string length? D = new Date(Date(0)) captures the entire clock + date state?
Copy link to clipboard
Copied
Yes, that's correct.
Dan
Find more inspiration, events, and resources on the new Adobe Community
Explore Now