Muhammad wasif
Muhammad wasif

Reputation: 59

How do i get the current date in C#?

How do you get the current date (not time) in C# ?

Example:

19/03/2011 

[Edit] I got the solution. thanks for answering... :)

DateTime dt = DateTime.Now; 

string sDate = dt.ToShortDateString();

Upvotes: 2

Views: 40745

Answers (2)

Daniel Hilgarth
Daniel Hilgarth

Reputation: 174289

Use DateTime.Today:

var today = DateTime.Today;

Upvotes: 19

Yuck
Yuck

Reputation: 50825

System.DateTime.Now.Date will get the date part only. It actually gives you the date at midnight.

Upvotes: 7

Related Questions