Use the ToLongTimeString() and ToShortTimeString() methods to convert the time parts of a DateTime to long and short time strings : DateTime Format « Date Time « C# / CSharp Tutorial

C# / CSharp Tutorial
1. Language Basics
2. Data Type
3. Operator
4. Statement
5. String
6. struct
7. Class
8. Operator Overload
9. delegate
10. Attribute
11. Data Structure
12. Assembly
13. Date Time
14. Development
15. File Directory Stream
16. Preprocessing Directives
17. Regular Expression
18. Generic
19. Reflection
20. Thread
21. I18N Internationalization
22. GUI Windows Forms
23. 2D
24. Design Patterns
25. Windows
26. XML
27. ADO.Net
28. Network
29. Directory Services
30. Security
31. unsafe
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
C# / CSharp Tutorial » Date Time » DateTime Format 
13. 3. 10. Use the ToLongTimeString() and ToShortTimeString() methods to convert the time parts of a DateTime to long and short time strings
using System;

class MainClass
{
  public static void Main()
  {
    DateTime myDateTime11 = new DateTime(20041152325);
    Console.WriteLine("myDateTime11 = " + myDateTime11);
    Console.WriteLine("myDateTime11.ToLongTimeString() = " +  myDateTime11.ToLongTimeString());
    Console.WriteLine("myDateTime11.ToShortTimeString() = " +  myDateTime11.ToShortTimeString());
  }
}
myDateTime11 = 15/01/2004 11:02:05 PM
myDateTime11.ToLongTimeString() = 11:02:05 PM
myDateTime11.ToShortTimeString() = 11:02 PM
13. 3. DateTime Format
13. 3. 1. Format time and date: {0:hh:mm tt}
13. 3. 2. Format time and date: 24 hour time is {0:HH:mm}
13. 3. 3. Format time and date: Date is {0:ddd MMM dd, yyyy}
13. 3. 4. Format time and date: Date is {0:gg}
13. 3. 5. Format time and date: Time with seconds{0:HH:mm:ss tt}
13. 3. 6. Format time and date: Use m for day of month{0:m}
13. 3. 7. Format time and date: use m for minutes: {0:%m}
13. 3. 8. Format time and date information.
13. 3. 9. Use the ToLongDateString() and ToShortDateString() methods to convert the date parts of a DateTime to long and short date strings
13. 3. 10. Use the ToLongTimeString() and ToShortTimeString() methods to convert the time parts of a DateTime to long and short time strings
13. 3. 11. Use the ToString() method to convert a DateTime to a string: MMMM dd, yyyy
13. 3. 12. Use the ToString() method to convert a DateTime to a string: d, D, f, F, g, G, m ,r, s, t,T, u, U, y
13. 3. 13. Pre-built date/time specifiers
w___w___w__.__j_a___va2s___.__c___o_m___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.