Custom Date Format with Language using c#

Posted: January 21, 2013 in
Tags: ,

Sometimes we require to change the format of date according to current culture. Those who are working on Multilingual websites must be facing this problem .

I`ll Give you A Simple Example How You Can Do This..


I had made this custom function you can use to Change the date format according to culture.


You Have To write this code in your .cs file

public static string GetDateString(string Date, string InputFormat, string OutputFormat, string Lang)
string fromformat = “MMMM dd, yyyy”; //Default value of input format
string toformat = “MM/dd/yyyy”;  //Default value of output format
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(Lang);
if (!string.IsNullOrEmpty(InputFormat))
fromformat = InputFormat;
if (!string.IsNullOrEmpty(OutputFormat))
toformat = OutputFormat;
string newdate = System.DateTime.Now.Date.ToString(toformat);
newdate = System.DateTime.ParseExact(Date, fromformat, System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat).Date.ToString(toformat);
catch (Exception ex)
return newdate;



In this function you have to input 4 parameters. 

1. Your date.

2.Current format of date.

3. Desired format of date.

4. Language.

This will return the date in desired format.

This Is Basic , Now You Can Modify This Code as You Want 🙂

Hope This Post Will Help you Somehow . . :); . Feel Free To Ask Anything You Need.

Waiting For Your Valuable Feedback.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s