get (-) when i try too input the value for my input type="time"
error: (The specified value "08:-30" does not conform to the required format. The format is "HH:mm", "HH:mm:ss" or "HH:mm:ss.SSS" where HH is 00-23, mm is 00-59, ss is 00-59, and SSS is 000-999.)
7 Replies
edit: i know it has to do with my calculation
where if i have the end time 0 it will bugg out like that
math on time is best done in unix epoch format
convert start and end to epoch, subtract the two numbers, then convert back to hours and minutes from second
i am still very new too javascript so if you would have a article or reference about it i would love to read it
is epoch a function?
computers usually store time in a format that's called Unix Epoch or Unix Timestamp. It's simply a very big number which represents the number of seconds since 0:00 on January 1st 1970
working with times is a bit of a nightmare in Javascript though
hmm i see, my goal was too just have a start time and end time and get the total time for it. I thought it would be a little easier xd. You got some advice on what i could do instead or alternative way to do it?
i am not trying to work with current time just with 2 times you put in yourself
in this case, I'd probably convert time to seconds manually. Multiply hours by 3600, minutes by 60. Then take those two totals, subtract them, and then turn them back into hours and minutes
ahhh good idea ill try that, thanks