Long date using Culture Information

Long date using Culture Information

In this example we will see how to get long date string. we will use CultureInformation and DateTime using C#.net and Vb.net

C#.net long date format

Example
using System;
using System.Globalization;
using System.Threading;
namespace DateAndTime.Example
{
class Program
{
static void Main(string[] args)
{
CultureInfo ci = new CultureInfo("en-GB");       
Thread.CurrentThread.CurrentCulture = ci;           
string inputDate = "31-12-2011";      
DateTime dt = DateTime.Parse(inputDate);            
Console.WriteLine("Long input date is {0}",dt.ToString(ci.DateTimeFormat.LongDatePattern,ci.DateTimeFormat ));
Console.ReadLine();
}
}
}

Vb.Net example of get date time in long format

Imports System.Globalization
Imports System.Threading
Namespace DateAndTime.Example
Class Program
Private Shared Sub Main(args As String())
Dim ci As New CultureInfo("en-GB")
Thread.CurrentThread.CurrentCulture = ci

Dim inputDate As String = "31-12-2011" Dim dt As DateTime = DateTime.Parse(inputDate) Console.WriteLine("Long input date is {0}",
	            dt.ToString(ci.DateTimeFormat.LongDatePattern, ci.DateTimeFormat))

Console.ReadLine() End Sub End Class End Namespace
long date time format

Output Long input date is 31 December 2011

Other Date time examples

Get Date and time in English UK format. 
English UK format Date and Time

Tags:

C# DateTimeLong date using Culture InformationDateTimeTryParse using C# and VB.net exampleC# DateTime DifferenceC# Parse method of DateTimeAsp.net Cache ObjectDateTime.Today Vs DateTime.NowC# DateTime ToString()DateTime in C# current Date and TimeDate Time in English United KingdomC# Convert String To DateTime

Author

My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.
 

I'm Satalaj.