Datediff calculation

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.

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?

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? :slight_smile:

Regards!

Hi @sariwest,

You can use d.getFullYear() (d is a Date object as in the sample code above)

Regards