Hi, Jake -- Welcome to the community! We're glad you're here. :)
You may already be aware of this, but we do not provide support for JavaScript coding, however, it may be helpful to take a look at this document on JavaScript Best Practices. Hopefully, some of our JS experts in the community can chime in with suggestions!
var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");var today = new Date(); var dd = today.getDate(); var mm = today.getMonth();//+1; //January is 0! var yyyy = today.getFullYear(); if(dd<10) { dd='0'+dd } var date= m_names[mm]+' '+dd+', '+yyyy;
You can add it with these additional lines of code.
var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");var today = new Date(); var dd = today.getDate(); var mm = today.getMonth();//+1; //January is 0! var yyyy = today.getFullYear(); if(dd<10) { dd='0'+dd } var suffix = "th"; if(dd == 1){ suffix="st"; } if(dd == 2){ suffix="nd"; } if(dd == 3){ suffix="rd"; } var date= m_names[mm] + ' ' + dd + suffix + ', ' + yyyy;
I havent tested it, but this should work. It can also be accomplished with switches rather than if/thens.
This is the code I am using at the moment and its displaying the date like this
6 August 2015
var currentTime = new Date()
var month=new Array(); month[0]="January"; month[1]="February"; month[2]="March"; month[3]="April"; month[4]="May"; month[5]="June"; month[6]="July"; month[7]="August"; month[8]="September"; month[9]="October"; month[10]="November"; month[11]="December"; var monthSpelled = month[currentTime.getMonth()]; var day = currentTime.getDate() var year = currentTime.getFullYear() var dateString=day + " " + monthSpelled + ", " + year var player = GetPlayer(); player.SetVar("SystemDate",dateString);
6 Replies
Hi, Jake -- Welcome to the community! We're glad you're here. :)
You may already be aware of this, but we do not provide support for JavaScript coding, however, it may be helpful to take a look at this document on JavaScript Best Practices. Hopefully, some of our JS experts in the community can chime in with suggestions!
If your code looks something like this:
You can add it with these additional lines of code.
I havent tested it, but this should work. It can also be accomplished with switches rather than if/thens.
Let me know if it works, I hope this helps!
Thanks so much for the suggestion, Jackson, and I hope it does the trick for Jake! :)
this accounts for the 11th, 21st, etc
This post was removed by the author
This is the code I am using at the moment and its displaying the date like this
6 August 2015
var currentTime = new Date()
var month=new Array();
month[0]="January";
month[1]="February";
month[2]="March";
month[3]="April";
month[4]="May";
month[5]="June";
month[6]="July";
month[7]="August";
month[8]="September";
month[9]="October";
month[10]="November";
month[11]="December";
var monthSpelled = month[currentTime.getMonth()];
var day = currentTime.getDate()
var year = currentTime.getFullYear()
var dateString=day + " " + monthSpelled + ", " + year
var player = GetPlayer();
player.SetVar("SystemDate",dateString);
SystemDate is the variable I'm using
Thanks for sharing this, it works perfectly!
This discussion is closed. You can start a new discussion or contact Articulate Support.