0

How can I create a string in the format "hh.mm" from a given TimeSpan object?

The opposite of what is wanted in this question. I've got a valid TimeSpan object and want to parse it into a string of the given format. Two digits for he hours, a dot and two digits for the minutes.

I tried using it with the format string "hh.mm" like I would've done it with an DateTime object. This did not work.

TimeSpan.FromMinutes(120).ToString("hh.mm")

This throws a System.FormatException.

Community
  • 1
  • 1
Philipp M
  • 1,877
  • 7
  • 27
  • 38

0 Answers0