"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Thursday, May 6, 2010

DateTime Format in ASP.NET


Date and Time is almost used in all application.Here we discuss about the date time format in asp.net.
we can set datetime format following are some formats.

d - day of the month, like 2
dd - day of month ,like 02 it leads 0
ddd - first 3 character of the name of the week day, like Mon
ddd - Full name of the week day, like Monday

M - Month without leading 0, like 2
MM - Month with lading 0, like 02
MMM - first 3 character of month name ,like Jan
MMMM- full name of month ,like January

yy - it shows year like 09
yyyy - it show full year, like 2009

h - it show hour like 2 it does't contains leading 0
hh - it contains leading 0 ,like 03

m - it shows minutes ,like 3
mm - it shows,like 03

s - second without leading 0, like 3
ss - second with leading 0,like 03



use above format some examples are given below.
Pattern Display format



M/d/yyyy 2/3/2008

MM/dd/yyyy 02/03/2008

MMM/ddd/yy Jan/Mon/08

MMMM/dddd/yyyy January/Monday/2008

MMMM,dddd,yyyy January,Monday,2008,

MMMM,dddd dd,yyyy Monday,January 03,2008

MMMM,dddd,yyyy h:mm tt January,Monday,2008 1:34 PM

MMMM,dddd,yyyy h:mm:ss tt January,Monday,2008 1:34:15 PM



Have a nice day... 'N happy Coding :)

MalenaCollage Fusion: Vibrant Wood and Fabric Art using Telamadera Techniques

No comments: