Menu

Date Format in asp.net

Declare Namespace.

using System.Globalization;

Declare “DateTimeFormatInfo” object here.

DateTimeFormatInfo dateFormat = new DateTimeFormatInfo();

Pass here your Date Formate.

dateFormat.ShortDatePattern = "dd-MM-yyyy";

Pass here your date separator.

        dateFormat.DateSeparator = "-";

Pass here your String Date and DateFormat in Convert.ToDateTime().

        Convert.ToDateTime("25-10-2012", dateFormat);

No comments

Leave a Reply


9 + 7 =

Categories