Reputation: 3893
I need to convert a variable from System.DateTime type to related amount of minutes of integer type E.g.
4:00AM = 240 minutes
(amount of minutes from the beginning of the day to 4:00AM),
12:00 = 720 minutes, 23:00 = 1380 minutes.
Is there any .net utility function?
Upvotes: 0
Views: 51
Reputation: 460288
You can use TimeSpan.TotalMinutes
, you get the timespan from DateTime.TimeOfDay
:
DateTime now = DateTime.Now;
int minutes = (int) now.TimeOfDay.TotalMinutes;
Upvotes: 4