Set current time at Timeinput by clicking a button - Forum

Forum Navigation
You need to log in to create posts and topics.

Set current time at Timeinput by clicking a button

How to set the current time at Timeinput by clicking a button?

Uploaded files:
  • You need to login to have access to uploads.

@asmat try this:

BeginJS
    $App.time = new Date();
EndJS

You should assign [time] as the TimeInput variable.

Regards.

asmat has reacted to this post.
asmat

Or try this if you want to show the hour and minutes only:

BeginJS
    let currentTime = new Date();
    let hours = currentTime.getHours();
    let minutes = currentTime.getMinutes();
    let formattedTime = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
    document.getElementById('TimeInput1').value = formattedTime;
    $App.time=formattedTime;
EndJS

 

asmat and javadrajabihakami have reacted to this post.
asmatjavadrajabihakami

Thank you so much master luishp!