I need convert 1815 minutes to 30:15 (30 hours and 15 minutes)
Is there an easy way to do this that I am missing?
All you need to do is divide your minutes by 60. For example, say your employee worked 20 hours and 15 minutes during the week. Divide your total minutes by 60 to get your decimal. For this pay period, your employee worked 20.25 hours.
There are 60 minutes in 1 hour. To convert from minutes to hours, divide the number of minutes by 60. For example, 120 minutes equals 2 hours because 120/60=2. Created by Sal Khan.
For example 15 minutes (¼ hour) equals . 25, 30 minutes (½ hour) equals . 5, etc.
Use TimeSpan.FromMinutes
:
var result = TimeSpan.FromMinutes(1815);
This will give you an object that you can use in different ways.
For example:
var hours = (int)result.TotalHours;
var minutes = result.Minutes;
you can use this function
//minutes to be converted (70minutes = 1:10 hours)
int totalminutes = 70;
//total hours
int hours = 70 / 60;
//total minutes
int minutes = 70 % 60;
//output is 1:10
var time = string.Format("{0} : {1}", hours, minutes);
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