Skip to content
Advertisement

How to calculate average time

how to calculate average time with 11:59:00 PM and 12:00:00 AM so that it can be 11:59:30 PM. currently this code is giving me 11:59:30 AM

JavaScript

Advertisement

Answer

This is a function for if you are looking for an average time given a set of times, regardless of date, given a 24 hr period. It works for 12am – 12pm but not 12pm – 12am (because that spans 2 days). If you are spanning days, you must use my first answer which requires the entire date be given in the time being evaluated.

jsFiddle

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement