Expression Copied to Clipboard! 🗂
← Back to Expressions

Get Current Date and Format - After Effects Expression

Useful snippet for getting current date

Get Current Date and Format

d = new Date(Date(0));
// Format Settings
divider = "/"
yearLength = 2; // use 2 for YY, 4 for YYYY

function padZeros(n){
 if(n <= 9){
   return "0" + n;
 }
 return n
}
yearTrim = (yearLength===2) ? 2 : 0;
"" + padZeros(d.getMonth()+1) + divider + padZeros(d.getDate()) + divider + d.getFullYear().toString().substring(yearTrim,4);

Copied to Clipboard!
d = new Date(Date(0));
// Format Settings
divider = "/"
yearLength = 2; // use 2 for YY, 4 for YYYY function padZeros(n){ if(n <= 9){ return "0" + n; } return n
}
yearTrim = (yearLength===2) ? 2 : 0;
"" + padZeros(d.getMonth()+1) + divider + padZeros(d.getDate()) + divider + d.getFullYear().toString().substring(yearTrim,4);

This expression grabs the current date and formats into MM/DD/YY

More expressions you might like...

Credit