How to allow time 24:00 in a field with mask hh:mm

shahabpk 06 Aug, 2019
I created a form with two time time input fields where users can enter in & out times and a third calculation field to find the duration by subtracting in from out time. Everything works correctly except that the time field allow entry up to 23:59 which makes the duration calucation incorrect when the out time is end of the day. (24:00)

Is there a way solve this like allowing 24:00 time in hh:mm mask etc??
shahabpk 26 Aug, 2019
After some digging inside the jquery.inputmask.js file , When I commented out the following part of the code, now time up to 24:59 can be entered in a field with input mask hh:mm.
/*
if ("24" === e.hourFormat && 24 === parseInt(a, 10)) return b.buffer[c - 1] = "0", b.buffer[c] = "0",
{
refreshFromBuffer:
{
start: c - 1,
end: c
},
c: "0"
};
*/

What I need now is to allow only 00 in minutes part when hour hh is 24. Can anyone be helpful ?
GreyHead 26 Aug, 2019
Hi shahabpk,

The documentation here for the InputMask library may help you.

Bob
healyhatman 26 Aug, 2019
In 24 hour time I'm pretty sure there's no such thing as 24:00, it goes back to 0:00
shahabpk 29 Aug, 2019
1 Likes
healyhatman is correct. But As a historical practice we use 24:00 time to indicate the end of the day and 00:00 as the beginning of the day. Since date is not included with time while saving the data, 24:00 is better to validate time overlap with other entries. Mysql time field allows entry 24:00, even though php takes it as 00:00. Its okay if the mask allows the entry. Meanwhile I was able to write some custome javascript to reset the field if user enters time greater than 24:00 say 24:30.
This topic is locked and no more replies can be posted.