Forum Discussion

UCICAsociacinCi's avatar
UCICAsociacinCi
Community Member
4 months ago

How to show onscreen time and date in real time?

Hello, 

I'm making a simulator and want to show the current date and time. 

I got to make work the date, but i'm finding it difficult for the time to work. 

I would appreciate some help,

Thank you

  • Try this:

    const currentTime = new Date();
    const timeString = `${currentTime.getHours()}:${(currentTime.getMinutes() < 10 ? '0' : '')}${currentTime.getMinutes()}`;

    setVar("HoraAhora", timeString);