
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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
- Related Questions & Answers
- C# General Date Short Time ("g") Format Specifier
- Full Date Long Time ("F") Format Specifier in C#
- Long Date ("D") Format Specifier in C#
- Long Time ("T") Format Specifier in C#
- Full Date Short Time ("f") Format Specifier in C#
- Short Date ("d") Format Specifier
- Short Time ("t") Format Specifier in C#
- C# Currency ("C") Format Specifier
- C# Hexadecimal ("X") Format Specifier
- C# Percent ("P") Format Specifier
- C# Decimal ("D") Format Specifier
- Month ("M", "m") Format Specifier in C#
- Sortable ("s") Format Specifier in C#
- C# Round-trip ("R") Format Specifier
- Year Month ("Y") Format Specifier in C#
Advertisements