Need date on a certificate image in SL3 May 01, 2020 By Roberta Collins I am building a course in SL3. I have an image of a certificate where the date is blank. Is there a way to add the current date when the image appears and print certificate with the current date on it?
Sanduni Fernando almost 4 years ago05/02/20 at 11:45 am (UTC) Hi Roberta, Follow the below steps: 1. Create a variable as "currentDate" 2. Use "Execute Javascript" when the time timelines starts for the slide. 3. Write this javascript; 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 } if (mm == 1) { var m_text = 'January' } if (mm == 2) { var m_text = 'February' } if (mm == 3) { var m_text = 'March' } if (mm == 4) { var m_text = 'April' } if (mm == 5) { var m_text = 'May' } if (mm == 6) { var m_text = 'June' } if (mm == 7) { var m_text = 'July' } if (mm == 8) { var m_text = 'August' } if (mm == 9) { var m_text = 'September' } if (mm == 10) { var m_text = 'October' } if (mm == 11) { var m_text = 'November' } if (mm == 12) { var m_text = 'December' } date = dd + '-' + m_text + '-' + yyyy; var player = GetPlayer();player.SetVar("currentDate",date); NOTE: You will see the date only when the course is published. You won't see the date on SL preview as JS are not running on preview. I have attached a sample file here. Let me know if you require any other information. CurrentDate.story
Roberta Collins Author almost 4 years ago05/06/20 at 1:41 am (UTC) Thank you so much for responding with this solution. It worked!
Shari Brewer over 1 year ago08/11/22 at 12:04 am (UTC) Roberta and Sanduni - thank you for this question and answer...I needed it today and it also worked for me. Woo hoo!
3 Replies
Hi Roberta,
Follow the below steps:
1. Create a variable as "currentDate"
2. Use "Execute Javascript" when the time timelines starts for the slide.
3. Write this javascript;
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
}
if (mm == 1) {
var m_text = 'January'
}
if (mm == 2) {
var m_text = 'February'
}
if (mm == 3) {
var m_text = 'March'
}
if (mm == 4) {
var m_text = 'April'
}
if (mm == 5) {
var m_text = 'May'
}
if (mm == 6) {
var m_text = 'June'
}
if (mm == 7) {
var m_text = 'July'
}
if (mm == 8) {
var m_text = 'August'
}
if (mm == 9) {
var m_text = 'September'
}
if (mm == 10) {
var m_text = 'October'
}
if (mm == 11) {
var m_text = 'November'
}
if (mm == 12) {
var m_text = 'December'
}
date = dd + '-' + m_text + '-' + yyyy;
var player = GetPlayer();
player.SetVar("currentDate",date);
NOTE: You will see the date only when the course is published. You won't see the date on SL preview as JS are not running on preview.
I have attached a sample file here.
Let me know if you require any other information.
Thank you so much for responding with this solution. It worked!
Roberta and Sanduni - thank you for this question and answer...I needed it today and it also worked for me. Woo hoo!
This post was removed by the author