Solved

displaying a time without the seconds.

Posted on 2008-10-01
2
206 Views
Last Modified: 2009-07-29
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?
0
Comment
Question by:scm0sml
2 Comments
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 22615748
litEndTime.Text = _endTime.TimeOfDay.ToString("HH:mm")
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 22616267
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

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Binding a check box in an Asp.net DataGrid 4 26
Showdialog 8 20
Calling stored proc in EDMX 11 19
ASP.NET reading ATOM 2 26
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now