Using variables to set progressive dates


I found a post that showed how you can use variables and triggers to automatically display the current date.



var currentDate = new Date()
var day = currentDate.getDate()
var month = currentDate.getMonth() + 1
var year = currentDate.getFullYear();
var player = GetPlayer();
var newName = day + "/" + month + "/" +year
player.SetVar("DateValue", newName);

DateValue is my variable in the storyline, it should be a text value

(per post by Sinchu Raj)


Does anybody know if I can use variable and triggers to have the system calculate a future date? For example, if I have a progressive scenario that starts on today's date but future actions happen in 1.5 months, 3 months and so on ... Is there a code that I can use to have the system obtain todays date then calculate the date in those intervals?


Any help would be appreciated!!


3 Replies
Krista Mikkelsen

Thanks Seth!!

That gave me the framework to figure out the coding I needed. For anybody else who might be interested, here is the code that worked for me. 


var targetDate = new Date();

targetDate.setDate(targetDate.getDate() + 20);

var monthArray = new Array ("January","February","March","April","May","June","July","August","September","October","November","December");

var month = targetDate.getMonth();

var theMonth = monthArray[month];

var dd = targetDate.getDate();

var yyyy = targetDate.getFullYear();

var dateString = theMonth + " " + dd + ", " + yyyy;

var player = GetPlayer();


The "+20" in the first row is the number of days added to the current date, and the date is formatted as month, day, year - example "November 19, 2014".

Thanks again to a fabulous community that always seems to be able to help me with my questions and issues!