Display Current Date and Time

I have a client that would like me to display the current day and time on his website. I have added the following code and an able to display the date, but I have no idea how to format the script to also display the current time.

// Gets today’s date
const today = new Date();
// Sets the property of the text element to be a string representing today’s date in the user’s local format
$w(“#text1”).text = today.toLocaleDateString();

Here is a link to my test page:
https://www.nocoweb.com/test-page

Any assistance is greatly appreciated!
Thanks,
Sue

3 Likes

I figured it out - thought I’d paste what I did in here in case anyone else needs it:

// Gets today’s date and time
const today = new Date();
// Sets the property of the text element to be a string representing today’s date in the user’s local format
$w(“#text1”).text = today.toLocaleDateString();
$w(“#text12”).text = today.toLocaleTimeString();

https://www.wix.com/corvid/forum/community-discussion/time-display-does-not-advance

@muthu This is an old post which is being closed.