none
UK Date Format

    Question

  • How can i get todays date in the UK format? It seams to return an American format by default, and i can't find any documentation on how to change it.

    Thanks,

    Steve

    Tuesday, November 29, 2005 7:27 PM

Answers


  • DateTime dt = DateTime.Now;

    System.Globalization.CultureInfo uk = new System.Globalization.CultureInfo("en-GB");//creates a new CultureInfo object based upon a culture code, here en-GB

    string s =dt.ToString(uk.DateTimeFormat);

    string s2 = dt.ToString("dd.MM.yyyy hh:mm:ss");//manualy prints a date, it can be set to fit what ever you need
    //d: day
    //M: month
    //y: year
    //h: hour
    //m: minute
    //s: second


     
    Tuesday, November 29, 2005 9:08 PM