converting time to ms for javascript