Display a TimeSpan formatted time

1

I have two variables:

        TimeSpan horaI = new TimeSpan(10, 00, 00);
        TimeSpan horaF = new TimeSpan(22, 00, 00);

I need to display them on the screen as follows 10:00 AM and 10:00 PM. But I can not do it.

How could I do this?

    
asked by anonymous 10.11.2015 / 14:24

1 answer

2

You can do this as follows:

var horaI = new TimeSpan(10, 00, 00);

var horaFormatada = string.Format("{0:hh\:mm}", horaI);

Of course there are several other ways to do this.

Source: link

    
10.11.2015 / 14:30