Just curious, is there a format string I can use to output something like “5h 3m 30s”?
eg. (obviously wrong)
myTimeSpan.ToString("hh mm ss")
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try:
(Note that even spaces need to be quoted – that’s what was wrong with my first attempt.)
I’m assuming you’re using .NET 4, of course – before that,
TimeSpandidn’t support custom format strings.EDIT: As noted, this won’t work beyond 24 hours. Also note that alternatives are available via Noda Time too 🙂