Is there any way to change the date format on the sys.metadate.currentDate input? It's set to YYYY/MM//DD.
2662 0 6Answers ( 6 )
Hi,
Currently the date format is fixed in the pattern you note. Date masking is not a feature we have on our roadmap since the date and format can be set to whatever you want in a custom variable and JavaScript or HTML widgets.
Here's a resource with javascript syntax on date formatting if you aren't familiar with it.
Comments
( 0 )Any hints on the custom variable and JavaScript method? Trying this and feel like I'm close, but still stuck. Thanks!
Comments
( 0 )For this response I will assume you are aware that in ONE all player control functions can be found in parent.contentApi (use parent over top so SCORM frames don't break your functions).
First you need to create the variable you want to use. I will call it myFormattedDate. Use the Set Variable action to create the variable you plan to use.
If you plan to display this variable, you will be able to find it by typing {{ in any text field and picking your custom variable.
//get todays date and format it M/D/YYYY
var t = new Date();
//JS stores months from 0-11, need to use +1 to get correct calendar month
var tempDate = (t.getMonth()+1) +'/'+ t.getDate() +'/'+ t.getFullYear();
//this will create a variable in the player that course content can use.
//this variable needs to be the same variable created using the Set Variable action
//if it is not created using Set Variable, the variable will not be available to use
//in actions or display in text fields etc...
parent.contentApi.setData('myFormattedDate', tempDate);
Comments
( 0 )parent.contentApi.setData('myFormattedDate', tempDate); <-- that's what I was missing, you are so awesome thank you!!!
Comments
( 1 )Hi Luke - is this still applicable for xapi? --> (use parent over top so SCORM frames don't break your functions)
I noticed for us for xapi - had to remove "parent", not sure if that is our platform or it's universal:
var t = new Date();
var tempDate = (t.getMonth()+1) +'/'+ t.getDate() +'/'+ t.getFullYear();
contentApi.setData('myFormattedDate', tempDate);
Thanks!
Comments
( 1 )Forgot to ask this question or clarofy the use of widgets vs Execute Javascript function. For execute javascript you do not need parent/top etc.. that will likely fail since the parents domain may not match. in the case of a widget you need parent to get to the "content" frame since a widget is an embedded iFrame.
Comments
( 0 )