Community X.

Connect with other creators, share ideas, give feedback and get the latest product updates.

Oct 20

How to show current time and date on the webpage using a text label according to visitor location geography

I would like to show a date and time label if auto detect timezone is too difficult... then I would atleast like the the option of selecting the timezone and have the server send me the time and date, to use those on a text label on a webpage and gets updated live probbaly every minute accuracy is preferred, is this possible using the built in server response, I am new to corvid editor, has anyone tried to achieve this?

4
Best Answer
Oct 20

https://idoh33.editorx.io/mysite-12


$w.onReady(function () {
    updateTime();
});


function updateTime() {
 
    setInterval(()=>{
 let date =new Date();
 let hours = date.getHours();
 let minutes = date.getMinutes();
 let seconds = date.getSeconds();
        $w('#text3').text = hours+':'+minutes+':'+seconds;
    },1000)
 
}

Amazing Ido you came to the rescue! The function seems so straight forward and easy to understand, It's been 5 years since I did any JS coding, so I feel little apprehensive to experiment, hopefully that change soon! Thank you for helping me, I'll try it out today and let you know how it goes :)

Ido, hello, I'm currently trying out the Updatetime function, I have to add a text label to the page and then assign the ID to the function? I have done that but the label seems to be not displaying in the page, am I missing anything here? :)

Load more replies
2

Hey Deepak, If I understand you correctly you want to display the time in the visitor's timezone. If you use javascript's Date object this should achieve what you want, check this out, it's supposed to answer your questions: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

I am aware of the function in javascript, but it would really be helpful if someone were to point me towards an implementation of the date and time function using the corvid interface with a tiny demo using editor x labels. If it's not too much trouble, but thank you for thesuggestionn, appreciate it :)

Editor X

Design your boldest creations.