Whaly's World tail -f /var/log/whaly

9Aug/092

The time separator

DateTime.Now.ToString("HH:mm:ss");

is a common mystake if you want to transmit to someone or to be sure that you have something like "HH:mm:ss" because the character (:) is not just a colon, it's a time separator wich depend on the locale.

Here is a list of culture where the (:) change into a dot (.)
it-IT : Italian (Italy)
fo-FO : Faroese (Faroe Islands)
bn-BD : Bengali (Bangladesh)
ml-IN : Malayalam (India)
bn-IN : Bengali (India)

To workaround you can use CultureInfo.InvariantCulture or escape the colon character.

... and same story for the date separator "/" but this one is at this time the same for every culture.

Comments (2) Trackbacks (0)
  1. In bn-BD culture Date separator is “-”.
    How can I get “/” separator instead of “-” separator using bn-BD culture?

  2. Hi, you can escape the date separator with a double “\”

    DateTime.Now.ToString("dd\\/MM\\/yyyy");

    and if you need to change the date separator everywhere in your application you can do something like :

    CultureInfo ci = new CultureInfo("bn-BD"); // or get the current culture
    ci.DateTimeFormat.DateSeparator = "/";
    Thread.CurrentThread.CurrentCulture = ci
    

Leave a comment

(required)

No trackbacks yet.