- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
General Date Long Time ("G") Format Specifier in C#
The General Date Long Time standard format specifier is a combination of the short date ("d") and long time ("T") patterns, separated by a space.
Set the date −
DateTime dt = new DateTime(2018, 1, 3, 3, 45, 20);
Now, use the ToString() method and DateTimeFormatInfo.
dt.ToString("G", DateTimeFormatInfo.InvariantInfo)
Example
using System; using System.Globalization; class Demo { static void Main() { DateTime dt = new DateTime(2018, 1, 3, 3, 45, 20); Console.WriteLine(dt.ToString("G", DateTimeFormatInfo.InvariantInfo)); } }
Output
01/03/2018 03:45:20
Advertisements