I just want to calculate timings as an input value and must display the number of minutes on the text box.
Eg:
Start time #input value1 - 10:00
End time #input value2 - 11:30
No of minutes #textbox1 - 1:30
Thank you in advance!
I just want to calculate timings as an input value and must display the number of minutes on the text box.
Eg:
Start time #input value1 - 10:00
End time #input value2 - 11:30
No of minutes #textbox1 - 1:30
Thank you in advance!
You can try:
$w.onReady(() => {
$w('#startTimeInput, #endTimeInput').onInput(event => {
if(!$w('#startTimeInput').value || !$w('#endTimeInput').value){return;}
const minutes = Math.floor(
(new Date($w('#endTimeInput').value).getTime()
- new Date($w('#startTimeInput').value).getTime()) / 60000
);
$w('#minutesText').text = minutes.toString();
})
})
Sorry. That was code for full date input.
If you want to use time input you need to do it differently.
But first let us now if the start time and the end time are always on the same day (same date).
@jonatandor35 Thanks
@jonatandor35 Yes. They are on the same day
@ppremkumar055 I had a typo. fixed.