473,569 Members | 2,870 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.ToLongTime String(); 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 1292
On Tue, 14 Oct 2008 10:51:21 -0700, puzzlecracker <ir*********@gm ail.com>
wrote:
I have this string string time =
System.DateTime .Now.ToLongTime String(); 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...@gm ail.comwrote:
I have this string *string time =
System.DateTime .Now.ToLongTime String(); 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...@construct ion-imaging.com wrote:
On Oct 14, 1:51*pm, puzzlecracker <ironsel2...@gm ail.comwrote:
I have this string *string time =
System.DateTime .Now.ToLongTime String(); 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.ToStrin g("HH:mm:ss") ;
"za***@construc tion-imaging.com" wrote:
On Oct 14, 1:51 pm, puzzlecracker <ironsel2...@gm ail.comwrote:
I have this string string time =
System.DateTime .Now.ToLongTime String(); 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
3856
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 what's happening and estimate how long it will take. In a script, I can put a GO after each PRINT to cause the output to appear immediately, but...
5
11072
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 the "Printing Page 1 of document.." dialog. Curently I use .Print() method. I found this article that solves problem within DevExp but i don't...
1
5693
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 of a Microsoft book, "Visual Basic,Net Step by Step" in Chapter 18. All but the bottom two subroutines will open a text file, and then allow me...
0
1019
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 - 10, s.Height - 36, currentTab); Graphics memoryGraphics = Graphics.FromImage(memoryImage); IntPtr dc1 = currentTab.GetHdc(); IntPtr dc2 =...
7
1533
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. The situation is this: I am writing fairly large console scripts in Python. They have quite a few command-line options, which lead to configuration...
9
3449
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 (no print dialog should pop). 3. Close word. All of this must be completely "transparent" to the user, just like a
0
1686
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 version. When trying to view a file manually Adobe 5.0 displays a pop up message: "This file may contain newer information than this viewer can...
3
1351
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 text. others are. code: $message = "A difference in /opt/local/bin has been noted: $opt_local_bin{$file}{'new'}{'file'} is now available\n";...
18
11271
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 classes, for each of the checked rows in the GridView. This works fine in the Visual Studio 2005 development environment on localhost. But, when I...
0
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7983
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6287
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5223
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
946
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.