Solved

displaying a time without the seconds.

Posted on 2008-10-01
2
211 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Expert Comment

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

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

740 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