Forum Discussion
JavaScript help
- 2 months ago
I don’t think holding the current date value in a text entry field is a good idea, as it can be easily overridden by the learner’s input. Instead, you can display the current date in a text box by referencing the current_date variable.
The JavaScript code for setting the current date is included in the attached .story file.
Hi, I am also looking for this. I have got my javascript to work however showing as mm/dd/yyyy however want it to show as dd month(long) yyyy (10th March 2025)
I tried to open your file that you attached however it doesn't allow me to open it 😑
Please could you copy and paste the javascript used at all?
Execute JavaScript when the timeline starts:
var options = { year: 'numeric', month: 'long', day: 'numeric' };
var currentDate = new Date().toLocaleDateString('en-GB', options);
setVar('currentDate', currentDate);
Ensure there is a custom text variable "currentDate" in your project.
- LucyLou2 months agoCommunity Member
That hasn't worked for me 😔 However I managed to work it out - thank you 😆