Forum Discussion
DonnaWestwood
9 years agoCommunity Member
Javascript date format dd/mm/yy NOT dd/mm/yyyy - do I need to import a library?
I am developing a software simulation which uses dates/ calendars extensively. (a booking system) Some javascript has already been used in this project, for example system date, year, month, day of ...
OwenHolt
9 years agoSuper Hero
Part 1 JS:
//Call the StoryLine player
var player=GetPlayer();
//Get today's date from the computer
var today = new Date();
//Isolate the day, the month and the year from the date
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yy = today.getFullYear().toString().substr(-2);
//combine the date elements as mm/dd/yy
//start by creating a leading zero for single digit days and months
if(dd<10) {
dd='0'+dd
}
if(mm<10) {
mm='0'+mm
}
today = mm+'/'+dd+'/'+yy;
//Send to StoryLine variable
player.SetVar("Today's_Date",today);