
- 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
Short Date ("d") Format Specifier
The "d" format specifier represents a custom date and time format string.
The format string is defined by culture's DateTimeFormatInfo.ShortDatePattern property.
The custom format string is −
MM/dd/yyyy
Example
using System; using System.Globalization; class Demo { static void Main() { DateTime myDate = new DateTime(2018,9, 09); Console.WriteLine(myDate.ToString("d", DateTimeFormatInfo.InvariantInfo)); Console.WriteLine(myDate.ToString("d", CultureInfo.CreateSpecificCulture("en-US"))); } }
Output
09/09/2018 9/9/2018
- Related Questions & Answers
- Long Date ("D") Format Specifier in C#
- C# General Date Short Time ("g") Format Specifier
- C# Decimal ("D") Format Specifier
- Full Date Short Time ("f") Format Specifier in C#
- Short Time ("t") Format Specifier in C#
- C# Hexadecimal ("X") Format Specifier
- C# Percent ("P") Format Specifier
- C# Currency ("C") Format Specifier
- General Date Long Time ("G") Format Specifier in C#
- Full Date Long Time ("F") Format Specifier in C#
- Month ("M", "m") Format Specifier in C#
- C# Round-trip ("R") Format Specifier
- Sortable ("s") Format Specifier in C#
- Long Time ("T") Format Specifier in C#
- Year Month ("Y") Format Specifier in C#
Advertisements