You can define the duration of the flight as a TimeSpan
:
var flightDuration = new TimeSpan(1, 45, 0);
I'd suggest using DateTimeOffset
rather than DateTime
, since it includes the time zone as part of the value.
If you use the + operator to add a TimeSpan
duration to a starting DateTimeOffset
, you get the result as a DateTimeOffset
. (This also applies to DateTime
s, if you prefer to stick with those.)
Use ToString()
to format it, like you would with DateTime
, passing it a string like "MMMM d HH:mm"; but be aware that there is currently no way of formatting ordinals, so although it's easy to get "July 6 01:30", there's no easy way to get "July 6th 01:30".
More information about Choosing between DateTime and DateTimeOffset.