Hey, I wanted to display the date on my Website. So, I got the code from Wix Help Center.
Here is the Link https://support.wix.com/en/article/velo-formatting-dates (at the bottom)
The code shows an error (options) but displays the date correctly as in the screenshot.
How do I fix the error?
Also, will the date automatically adjust according to the country the page is visited from?
Lastly, I want the date to appear like “It’s 31 May today” rather than “31 May”. Please help me achieve that.
Thanks in advance.
Send me the Code here. I will edit and Give you the Correct Code
$w.onReady(function () {
displayDate();
});
function displayDate() {
let today = new Date();
let day = today.getDate();
let month = today.toLocaleString('default', { month: 'short' });
console.log("day =" + day);
console.log("Month =" + month);
$w("#text89").text = "It's " + day + " " + month + " Today"
}
$w . onReady ( function () {
displayDate ();
});
function displayDate () {
let today = new Date ();
let day = today . getDate ();
let month = today . toLocaleString ( ‘default’ , { month : ‘long’ });
console . log ( “day =” + day );
console . log ( “Month =” + month );
$w ( “#text89” ). text = “It’s " + day + " " + month + " Today”
}
__ Use This Code If You Want “October” Instead of “Oct”
Although it’s flagged as an error, the code should work (I tried this myself). It’s a parsing/lint issue.
I’ve referred this issue to QA for evaluation.
Thanks a lot for your help!
A Question: Will the date automatically adjust according to the country the page is visited from? Like if it’s 31st May in the US, it might be the 1st of June in India.
Also, I have a text box and I want it to appear for 3 seconds. And then it fades away and the date fades in on its place.
Thanks.
You can inspect the IP address of the visitor to determine the country (search the forum for some examples), but you can’t guarantee what “country the page is visited from” as there are issues such as VPNs, and other networking issues. You can guess based on IP, and let the user change the country if they feel that your guess is incorrect.
For the text box, you can use setTimeout() , and then hide() the text box with the fade option.
@sheetalpbhatia
It will automatically show location based Date and time.
You may get 200 ms delay in conversation from UTC to your local
Like UTC -5
Or
UTC + 5:30
Thanks a lot guys for your replies! I’m building something never built with this platform. Will share the results here soon.