I need to insert a date that is 2 years from the current date, and the last day of that month. For example, the certification expires in 2 years (730 days) from today, and at the end of that month...so if I complete the course today (11/24/15), it will expire 11/30/17
You won't be able to do this reliably within Storyline - it's best to handle it through a controlled environment (such as a LMS). If you don't have/need a LMS, then you'll need a server side solution to make the checks and calculations. But that's nowhere near reliable or secure.
Ok, I totally misread your question - sorry it's already past midnight around here. I was thinking you needed validation towards those values.
You can totally achieve this by using Javascript. Best way to go about it is by using a library like date.js or moment.js, incorporating them via a web-object, then writing some library-specific code to calculate the correct expiration date.
The code to use is relevant not only to your calculation but the library you go with as well. So, first you have to choose a js library out of these two. Then you go about figuring out the code.
I'd personally go with moment.js, but to each his own.
I'm glad Steve and Alex are able to get you headed in the right direction in regards to the Javascript code. It's not something we can offer support for - so you'll want to continue to use the community assistance and also review the best practices for Javascript here.
Hi Steve, I've successfully used the code you provided several times, however for some reason, my latest courses are no longer displaying the calculated expiration date when I test them in LMS; they are just displaying %FormattedDatePlus2Yrs% on the slide. Could you please take a look at my attached slide and let me know what I'm doing wrong??
You don't have a variable established called "FormattedDatePlus2Yrs" in your list of variables in Storyline (you only have one called "FormattedDate"). In order to pass variables back and forth between Storyline and Javascript, the same variable name must exist/be used in both.
I was looking for a way to include both future dates and past dates on a slide. I was able to use the file that Steve created and build on it. I thought it might be helpful to the community to share what I built.
14 Replies
You won't be able to do this reliably within Storyline - it's best to handle it through a controlled environment (such as a LMS). If you don't have/need a LMS, then you'll need a server side solution to make the checks and calculations. But that's nowhere near reliable or secure.
Hope this helps,
Alex
Thanks Alex - so Storyline can reliably pull the current date, and a future date, but it can't reliably calculate the end of the month?
Ok, I totally misread your question - sorry it's already past midnight around here. I was thinking you needed validation towards those values.
You can totally achieve this by using Javascript. Best way to go about it is by using a library like date.js or moment.js, incorporating them via a web-object, then writing some library-specific code to calculate the correct expiration date.
Problem is, I can't figure out what code to use...
The code to use is relevant not only to your calculation but the library you go with as well. So, first you have to choose a js library out of these two. Then you go about figuring out the code.
I'd personally go with moment.js, but to each his own.
I don't have experience with JS and was hoping you could provide me with something I could copy and paste into my trigger...?
Hi Theresa,
Attached is a quick example. I have only tried this with today's date but it may get you started.
Hi Theresa,
I'm glad Steve and Alex are able to get you headed in the right direction in regards to the Javascript code. It's not something we can offer support for - so you'll want to continue to use the community assistance and also review the best practices for Javascript here.
Thanks so much Steve, I will give this a try!
Hi Steve, I've successfully used the code you provided several times, however for some reason, my latest courses are no longer displaying the calculated expiration date when I test them in LMS; they are just displaying %FormattedDatePlus2Yrs% on the slide. Could you please take a look at my attached slide and let me know what I'm doing wrong??
Thanks in advance, Theresa
Hi Theresa,
You don't have a variable established called "FormattedDatePlus2Yrs" in your list of variables in Storyline (you only have one called "FormattedDate"). In order to pass variables back and forth between Storyline and Javascript, the same variable name must exist/be used in both.
- Steve
You are a lifesaver; thank you so much!!!
Theresa
I was looking for a way to include both future dates and past dates on a slide. I was able to use the file that Steve created and build on it. I thought it might be helpful to the community to share what I built.
Thanks M for sharing here - these date/time examples tend to be a popular one!
This discussion is closed. You can start a new discussion or contact Articulate Support.