Library code snippets

How to display a date in a specific language

I do some of my developing on German servers which was always a drag when it came to formatting dates. With .NET you can set the culture info and it is taken care of automatically for you. Nice.

// using System.Globalization // stick this at the top of your class

CultureInfo ci = new CultureInfo("en-US");
DateTime dt = DateTime.Now;
Response.Write(dt.ToString("f",ci));

Response.Write("<br><br>");

DateTime dt2 = DateTime.MinValue;
Response.Write(dt2.ToString("f",ci));

Comments

  1. 01 Jan 1999 at 00:00

    This thread is for discussions of How to display a date in a specific language.

Leave a comment

Sign in or Join us (it's free).

AddThis

Related podcasts

  • Looking into the C# Crystal Ball with Charlie Calvert and Bill Wagner

    One of the most exciting announcements from PDC was the news about C# 4.0 and Visual Studio 2010. With all the excitement and discussion throughout the event about these new developer tools, we reached out to two experts in the fields. Charlie Calvert and Bill Wagner sat down with Keith and Woody...

Events coming up

  • Dec 6

    Developing AJAX Web Applications with Castle Monorail

    London, United Kingdom

    Monorail is the model-view-controller engine of the Castle Project, bringing many of the best ideas of Ruby on Rails to the .NET world. In this talk, David De Florinier and Gojko Adzic show how Monorail makes it easy to develop .NET based AJAX applications, and how to use the Castle Project to build Web 2.0 applications effectively. Come to this session if you are a .NET web developer. Everyone is welcome!