Thread: How do I format date as 10-Jan-1971 when regional setting is not English

  1. #1
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,794

    How do I format date as 10-Jan-1971 when regional setting is not English

    I have a Windows with Regional settings - Hebrew
    I have a consol application

    and I have
    Code:
    System.DateTime date = new System.DateTime(1971,1,10);
    System.Consol.WriteLine (date.ToString("dd-MMM-yyyy"));
    Which outputs some strange non-readable symbols instead of short month name.

    I'd like to see a month name or in Hebrew - or (preffered) ignoring regional settings of the windows - in English

    How do I do it?

    PS. I DO know how to output month as a number. I need a name.
    I have tried to change the CodePage of the Consol - no success.
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,794

    Found answer

    Aded at the beginning of the Main

    Code:
                    System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-us",false);
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 100000 women
    By Snafuist in forum A Brief History of Cprogramming.com
    Replies: 36
    Last Post: 05-27-2009, 07:41 AM
  2. reading a file
    By nhubred in forum C++ Programming
    Replies: 3
    Last Post: 05-21-2009, 11:34 AM
  3. A-Star Pathfinding
    By mike_g in forum General AI Programming
    Replies: 1
    Last Post: 08-05-2007, 04:18 PM
  4. Segmentation Fault
    By Lost__Soul in forum C Programming
    Replies: 46
    Last Post: 04-28-2003, 04:24 AM
  5. Scheduling Algo
    By BigDaddyDrew in forum C++ Programming
    Replies: 41
    Last Post: 03-08-2003, 11:00 AM