Solved

Changing the hour display

Posted on 2007-03-21
2
159 Views
Last Modified: 2010-04-23
Hi there,
How can i format the time in VS 2005?
right now i have the time display as 4:35 pm but i need instead to show 16::35pm
Thanks
0
Comment
Question by:jsctechy
  • 2
2 Comments
 
LVL 14

Accepted Solution

by:
jake072 earned 500 total points
ID: 18767187
Use:

DateTime.ToString("t")

That will result in 16:35.

It will not include pm, as that information is redundant...  If you need to include pm, then

DateTime.ToString("t") & CStr(IIf(DateTime.Now > 12, "pm", "am"))

You can also use DateTime.ToString("T") to display the seconds as well.

Jake
0
 
LVL 14

Expert Comment

by:jake072
ID: 18767190
NOTE: DateTime is a DateTime variable :)

If you want the current time, repleace DateTime with DateTime.Now.

Jake
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Prevent call a sub/function several times when data bind to gridview 21 33
VB.NET 2008 Publish Error 2 34
.NET 2008 VB and C# 6 39
VB.Net - String Manipulation Scenario 2 25
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

838 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