Problem: Is there a way to take a system variable like today’s date and add two years and have it printed to screen?
ActivePresenter Version: ActivePresenter Pro Edition
Version 8.0.7 - 64-bit build. (Released: 2020.05.29)
OS: Windows 10.
Notes: none.
ToanLS
(Toan Le)
July 16, 2020, 2:00am
2
Hi Robert,
It’s not possible with variables but you can use JavaScript to do that:
// current date time
var d = new Date();
// add two years
d.setFullYear(d.getFullYear() + 2);
// show it on an object in the slide
prez.object('object_name').text(d.toLocaleDateString());
Regards
1 Like
Amazing thank you!!! Is there a way to programmatically (sp?) concatenate the string "Expiry Date: " before printing the calculated date?
ToanLS
(Toan Le)
July 20, 2020, 1:56am
4
You can change the last statement in the script as follows:
prez.object('object_name').text('Expiry Date: ' + d.toLocaleDateString());
Regards
1 Like
Hey @ToanLS ,
is it possible that only the year and not the whole date is displayed?
Regards!
ToanLS
(Toan Le)
March 14, 2022, 2:09am
6
Hi @sariwest ,
You can use d.getFullYear()
(d
is a Date
object as in the sample code above)
Regards