Java Script Date Stuck

May 16, 2014

Hey there!

I took a bit of code from the forums here for a date stamp on my html certificate.  It seems to work fine the day I implement it, but then it gets stuck on that date and never changes.  

Does anyone know how to fix it so it's pulling the current date?

Thanks!

Here is the code:

    function FormatDate()

{

var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

var d = new Date();

var month = d.getMonth();

var date = d.getDay();

var year = d.getFullYear();

var d = m_names[month] + " " + date + ", " + year;

console.log(d);

return d;

}

var date = FormatDate();

    //grab timestamp in date format

4 Replies
Cynthia Phelps

Ok, this is now working...

var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

var d = new Date();

var month = d.getMonth();

var date = d.getDay();

var year = d.getFullYear();

var d = m_names[month] + " " + date + ", " + year;

console.log(d);

return d;

}

var date = FormatDate();

    //grab timestamp in date format

Christie Pollick

Hi, Bridget -- Thanks for your question! This thread is a bit older, so if you would like to reach out to the participants directly (as they may no longer be subscribed), you may do so using the 'Contact Me' link on their profile pages. 

And you may already be aware of this, but we do not provide support for JavaScript coding, however, it may be helpful to take a look at this document on JavaScript Best Practices. I hope some of our JS gurus in the community can chime in with suggestions! 

This discussion is closed. You can start a new discussion or contact Articulate Support.