Factored out calculation of difference in milliseconds