Forum Discussion
Date Format for System Date
Untested... but something like the following should get you the date string you are looking for.
var d = new Date();
var yyyy = d.getFullYear();
var month = ['January','February','March','April','May','June','July','August','September','October','November','December'];
var currentMonth = month[d.getMonth()];
var dayNames = ['Sunday','Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
var weekDay = dayNames[d.getDay()];
var daySyntax = ['1st','2nd','3rd','4th','5th','6th','7th','8th','9th','10th','11th','12th','13th','14th','15th','16th','17th','18th','19th','20th','21st','22nd','23rd','24th','25th','26th','27th','28th','29th','30th','31st'];
var dd = daySyntax[d.getDate()-1];
var todaysDate = weekDay + ", " + currentMonth + " " + dd + ", " + yyyy
console.log(todaysDate);
GetPlayer().SetVar("Your Date Variable In StoryLine",todaysDate);
Thank you for the quick reply!
After playing around with it for a bit, I was able to make it work how I needed by referencing %todaysDate% and executing the following JavaScript:
var d = new Date();
var yyyy = d.getFullYear();
var month = ['January','February','March','April','May','June','July','August','September','October','November','December'];
var currentMonth = month[d.getMonth()];
var dayNames = ['Sunday','Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
var weekDay = dayNames[d.getDay()];
var daySyntax = ['1st','2nd','3rd','4th','5th','6th','7th','8th','9th','10th','11th','12th','13th','14th','15th','16th','17th','18th','19th','20th','21st','22nd','23rd','24th','25th','26th','27th','28th','29th','30th','31st'];
var dd = daySyntax[d.getDate()-1];
var todaysDate = weekDay + ", " + currentMonth + " " + dd + ", " + yyyy
console.log(todaysDate);
var dateString=weekDay + ", " + currentMonth + " " + dd + ", " + yyyy
var player = GetPlayer();
player.SetVar("todaysDate",dateString);