displaying a time without the seconds.

I have the following:
litEndTime.Text = _endTime.TimeOfDay.ToString

where _endTime is of datatype Date.

When this is displayed i get:
16:22:01.4715497

i want:
16:22

how can i do this?
scm0smlAsked:
Who is Participating?
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
TimeOfDay() returns a TimeSpan instance which does NOT accept formatting options for ToString()...   =\

Just use ToString() directly on your DateTime like this:

    litEndTime.Text = _endTime.ToString("HH:mm")
0
 
copyPasteGhostCommented:
litEndTime.Text = _endTime.TimeOfDay.ToString("HH:mm")
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.