What would be a proper fool-proof way of doing so? I am using ASP.NET MVC 3.
If you'd like to calculate the difference between the timestamps in seconds, multiply the decimal difference in days by the number of seconds in a day, which equals 24 * 60 * 60 = 86400 , or the product of the number of hours in a day, the number of minutes in an hour, and the number of seconds in a minute.
To get a time difference in seconds, use the timedelta. total_seconds() methods. Multiply the total seconds by 1000 to get the time difference in milliseconds. Divide the seconds by 60 to get the difference in minutes.
You can use DiffSeconds() built-in function and multiply the result by 1000. The output will be milliseconds.
DateTime a = ...
DateTime b = ...
var ms = a.Subtract(b).TotalMilliseconds;
(datetime2 - datetime1).TotalMilliseconds
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With