Forum Discussion
Date Format for System Date
Hi there,
I followed the excellent advice and instructions from this thread for inserting a date into my Storyline
http://community.articulate.com/forums/p/12498/74794.aspx#74794 and I'm thrilled to say it's working just fine.
The date format is month/day/year but my course will be primarily used outside the US (where most countries record the date as day/month/year). I manged to change the order of the string instruction so that my output is now day/month/year but I would ideally prefer if the date came out as the word instead of the number. ie 15 January 2013 instead of either 1/15/13 or 15/1/13, as this would ensure the date was read properly globally.
I've tried searching the web for Javascript advice but I have no knowledge of JS and the advice is losing me completely! Can anyone suggest adjustment to the JS code that is recommended in the above thread, which is:
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
var dateString=month + "/" + day + "/" + year
var player = GetPlayer();
player.SetVar("SystemDate",dateString);
23 Replies
- DanielRosen1Community Member
Hi Miriam,
While researching something for a colleague, I ran across your post. Here's the modified code that will allow you to display the date the way you want:
var currentTime = new Date();
var monthArray = new Array ("January","February","March","April","May","June","July","August","September","October","November","December");
var month = currentTime.getMonth();
var theMonth = monthArray[month];
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var dateString= day + " " + theMonth + " " + year;
var player = GetPlayer();
player.SetVar("SystemDate",dateString); - MiriamKrajewskiCommunity Member
Thank you thank you thank you Daniel! That works perfectly now. I'm so excited, thank you!
- DanielRosen1Community Member
Happy to help.
- MikeWohlwendCommunity Member
Miriam Krajewski said:
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
var dateString=month + "/" + day + "/" + year
var player = GetPlayer();
player.SetVar("SystemDate",dateString);
Miriam, for future reference, the line with "var dateString" could probably have its later order shifted; looks like it is in this line that the order of month / day / year is established.If this script worked before, changing that line to:
var dateString=day + "/" + month + "/" + year
should also display it ordered as you want to see it.
So the nice thing is, sometimes code can be as comprehensible as that!
- KristinCarra-2cCommunity Member
Hi Kristin!
This thread is a bit dated and I'm not sure that the users here are still subscribed to the thread. JavaScript is not something that is supported by Articulate and I'm sure not an expert at it. Hopefully someone in the community will be able to chime in and assist you here.
- JiayuSunCommunity Member
Hi, i would also like to know whether it's possible to make date format as DDMMYYYY, thank you.
Hi Jiayu,
This discussion is still quite a bit older and I haven't seen that many other similar ones. Where are you looking to change the date format? If you'd like to update this in your Learning Management System (LMS) you may also want to reach out to your LMS admins to see if they can help!
- JiayuSunCommunity Member
Hi Ashley,
i want to show the date on one of the slide and by using javascript code mentioned above, the date shows like DD.M.YYYY, not DD.MM.YYYY, for example, 29.1.2018 instead of 29.01.2018
Ah, thanks Jiayu! I'll have to defer to the community to help with Javascript!
- KatarinaKlein-7Community Member
Is there a code to format the system date as:
Day of the week, month date, year
(for example: Tuesday, March 5th, 2019)
Related Content
- 5 months ago
- 2 months ago