How do you format Today's Date?

I would like to display today’s date on my homepage. I successfully used the code discussed here: https://support.wix.com/en/article/how-to-display-todays-date-on-your-site

However, I am unable to change the date format from 9/11/2018 to September 11, 2018.

It seems that this is possible when using a collection (Velo: Formatting Dates | Help Center | Wix.com) however I do not have a collection of data and simply wish to display the date.

Does anyone know how to modify the code for Today’s Date to accomplish this?

Thank you!

function getDate() {
 var month = new Array();
    month[0] = "January";
    month[1] = "February";
    month[2] = "March";
    month[3] = "April";
    month[4] = "May";
    month[5] = "June";
    month[6] = "July";
    month[7] = "August";
    month[8] = "September";
    month[9] = "October";
    month[10] = "November";
    month[11] = "December";

 var date = new Date();
 var dd = date.getDate();
 var mm = month[date.getMonth()];
 var yyyy = date.getFullYear();
    $w("#date").text = String(mm) + " " + String(dd) + ", " +  String (yyyy);
}

Enjoy !

1 Like

Thanks so much! I ended up using this instead:

function () {
const today = new Date();
const options = {
weekday: “long”,
day: “numeric”,
month: “long”,
year: “numeric”
};
$w(“#text3”).text = today.toLocaleDateString(‘en-US’, options);
});

1 Like