Using javascript to go to display date

Can anyone help? This is the javascript I have loaded on my 1 slide presentation. I have created variables, day1, month1 and year1.

var currentDate = new Date()
  var day = currentDate.getDate()
  var month = currentDate.getMonth() + 1
  var year = currentDate.getFullYear()
player.SetVar("day1", day);
player.SetVar("month1", month);
player.SetVar("year1", year);

 

However, when referencing these variables, it simply returns day1 = 0, month1 = 0 and year1 = 0. I thought it would pick up the date values on my computer. what am I doing wrong?

 

2 Replies
Michael Hinze

Add 'var player = GetPlayer();' and close each statement with ; so it looks like this:

var player = GetPlayer();
var currentDate = new Date();
var day = currentDate.getDate();
var month = currentDate.getMonth() + 1;
var year = currentDate.getFullYear();
player.SetVar("day1", day);
player.SetVar("month1", month);
player.SetVar("year1", year);