473,508 Members | 2,327 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

printing time in log messages

I have this string string time =
System.DateTime.Now.ToLongTimeString(); it is equal to 1:00:22 PM

I need it to be 13:00:22

Any suggestions how to format it?

Thanks
Oct 14 '08 #1
4 1286
On Tue, 14 Oct 2008 10:51:21 -0700, puzzlecracker <ir*********@gmail.com>
wrote:
I have this string string time =
System.DateTime.Now.ToLongTimeString(); it is equal to 1:00:22 PM

I need it to be 13:00:22

Any suggestions how to format it?
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
Oct 14 '08 #2
On Oct 14, 1:51*pm, puzzlecracker <ironsel2...@gmail.comwrote:
I have this string *string time =
System.DateTime.Now.ToLongTimeString(); it is equal to 1:00:22 PM

I need it to be 13:00:22

Any suggestions how to format it?

Thanks
string.Format("{0:HH}:{1:mm}:{2:ss}", Now, Now, Now)

This is just one of many ways it can be done.
Oct 14 '08 #3
On Oct 14, 1:56*pm, za...@construction-imaging.com wrote:
On Oct 14, 1:51*pm, puzzlecracker <ironsel2...@gmail.comwrote:
I have this string *string time =
System.DateTime.Now.ToLongTimeString(); it is equal to 1:00:22 PM
I need it to be 13:00:22
Any suggestions how to format it?
Thanks

string.Format("{0:HH}:{1:mm}:{2:ss}", Now, Now, Now)

This is just one of many ways it can be done.
Argh, I don't think sting has Format member function :(
Oct 14 '08 #4
The page peter posted is the best reference. Personally I prefer

System.DateTime.Now.ToString("HH:mm:ss");

our systems are in UTC

System.DateTime.UTCNow.ToString("HH:mm:ss");
"za***@construction-imaging.com" wrote:
On Oct 14, 1:51 pm, puzzlecracker <ironsel2...@gmail.comwrote:
I have this string string time =
System.DateTime.Now.ToLongTimeString(); it is equal to 1:00:22 PM

I need it to be 13:00:22

Any suggestions how to format it?

Thanks

string.Format("{0:HH}:{1:mm}:{2:ss}", Now, Now, Now)

This is just one of many ways it can be done.
Oct 14 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
347
by: Dave | last post by:
Hi, Can anyone direct me to any articles on the best way to give a print option in VB & ASP .net Cheers
2
3845
by: jim_geissman | last post by:
I have a script or SP that takes a very long time to perform multiple tasks, and after each one there is a PRINT statement that shows the time and what was just accomplished, to help me monitor...
5
11061
by: zeljko.markic | last post by:
I want to implement silent printing in my project to print reports programmatically, so that a user will not see any pop-up messages to do with the printing process. For instance, I want to hide...
1
5683
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out...
0
1013
by: melanieab | last post by:
Hi, When the print button is clicked, I save a snapshot of the screen to a bitmap file. Graphics currentTab = this.CreateGraphics(); Size s = this.Size; Bitmap memoryImage = new Bitmap(s.Width -...
7
1531
by: Leo Breebaart | last post by:
I have another question where I am not so much looking for a solution but rather hoping to get some feedback on *which* solutions people here consider good Pythonic ways to approach a issue. ...
9
3442
by: ewolfman | last post by:
Hi, I need to provide the user with the option to click something, and what follows is: 1. Download a word document, without displaying winword. 2. Printing the document to the default printer...
0
1681
by: Hank | last post by:
We have been printing pdf files through Adobe, from Access for several years. Adobe version 5.0 is currently installed. Recently we have received PDF files that were created under the Adobe 7.0...
3
1346
by: tbest4475 | last post by:
AIX I have a set of commands that run and if a difference is found it prints a message to an array and then sends that array in an email. certain messages are not printing the new line after the...
18
11264
by: Brett | last post by:
I have an ASP.NET page that displays work orders in a GridView. In that GridView is a checkbox column. When the user clicks a "Print" button, I create a report, using the .NET Framework printing...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7494
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5050
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.