Skip to content
Advertisement

Tag: time

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 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

Getting current date and time in JavaScript

I have a script that prints the current date and time in JavaScript, but the DATE is always wrong. Here is the code: It should print 18/04/2012 15:07:33 and prints 3/3/2012 15:07:33 Answer .getMonth() returns a zero-based number so to get the correct month you need to add 1, so calling .getMonth() in may will return 4 and not 5.

Advertisement