Forum Discussion
Need date on a certificate image in SL3
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?
3 Replies
- SanduniFernandoCommunity Member
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. - RobertaCollinsCommunity Member
Thank you so much for responding with this solution. It worked!
- ShariHanlon-c5fCommunity Member
Roberta and Sanduni - thank you for this question and answer...I needed it today and it also worked for me. Woo hoo!