Sample code to show date time in Month Day, Year format [C#]
using System;
using System.Globalization;
public class DateTimeFomrateString
{
public static void Main()
{
DateTime datetoFormat = new DateTime(2012, 1, 12);
Console.WriteLine("Today's Date is " + datetoFormat.ToString("MMMM dd, yyyy") + ".");
}
}
//Code will display the following output:
//Today's Date is June 10, 2011.
Here MMMM is format specifier that represents month as name like for 05 it will display May. dd is format specifier from day of the month with digits from 01 to 31 and yyyy is the format specifier with four digit number like 2012.
0 Comments :
Post a Comment