Search This Blog

Wednesday, August 10, 2011

Convert date and time in the desired format in vb,net


These codes help in formatting date and time in the desired format.

1.dd/MM/yyyy

String.Format("{0:dd/MM/yyyy}", DateTime.Now)

O/P = 19/12/2008

2.MM/dd/yyyy

String.Format("{0:MM/dd/yyyy}", DateTime.Now)

O/P = 12/19/2008


3.dd/MM/yy

String.Format("{0:dd/MM/yy}", DateTime.Now)

O/P = 19/12/08


4.t

String.Format("{0:t}", DateTime.Now)

O/P = 10:30 AM


5.F

String.Format("{0:F}", DateTime.Now)


o/p=Friday, December 19, 2008 10:48:46 AM

No comments:

Post a Comment