Manish Pansiniya's Blog

.NET, C#, Javascript, ASP.NET and lots more…:)

Custom date time & Standard date time format – Confused with “d” format

leave a comment »

There are one issue, we just got into. The issue is with DateTime object.

When you use following thing,

DateTime dtDate = DateTime.Today
dtDate.ToString(“d”)         >>       “29/04/2010”.

It gives you output “29/04/2010”. But actually, I need to use as custom DateTime format, which only return day.

For doing so, Microsoft provides custom format specifier and that is %. So if there is any standard date time format and it conflicts with Custom date time, you need to append % for using custom format.

DateTime dtDate = DateTime.Today
dtDate.ToString(“%d”)      >>         29

Just need to use % for custom date time.

Keep Smiling 🙂

Advertisements

Written by Manish

April 29, 2010 at 2:37 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: