Quantcast
Channel: C#: How would I get the current time into a string? - Stack Overflow
Browsing all 7 articles
Browse latest View live

Answer by Kartiikeya for C#: How would I get the current time into a string?

Method to get system Date and time in a single string public static string GetTimeDate() { string DateTime = System.DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss"); return DateTime; } sample OUTPUT...

View Article



Answer by Mike Scott for C#: How would I get the current time into a string?

Be careful when accessing DateTime.Now twice, as it's possible for the calls to straddle midnight and you'll get wacky results on rare occasions and be left scratching your head. To be safe, you should...

View Article

Answer by P Daddy for C#: How would I get the current time into a string?

I'd just like to point out something in these answers. In a date/time format string, '/' will be replaced with whatever the user's date separator is, and ':' will be replaced with whatever the user's...

View Article

Answer by palehorse for C#: How would I get the current time into a string?

You can use format strings as well. string time = DateTime.Now.ToString("hh:mm:ss"); // includes leading zeros string date = DateTime.Now.ToString("dd/MM/yy"); // includes leading zeros or some...

View Article

Answer by Joel Coehoorn for C#: How would I get the current time into a string?

string t = DateTime.Now.ToString("h/m/s tt"); string t2 = DateTime.Now.ToString("hh:mm:ss tt"); string d = DateTime.Now.ToString("MM/dd/yy"); http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

View Article


Answer by Tom Ritter for C#: How would I get the current time into a string?

DateTime.Now.ToString("h:mm tt") DateTime.Now.ToString("MM/dd/yyyy") Here are some common format strings

View Article

C#: How would I get the current time into a string?

How could I get the current h/m/s AM time into a string? And maybe also the date in numeric form (01/02/09) into another one?

View Article
Browsing all 7 articles
Browse latest View live




Latest Images