why does DateTime.ToString(“dd/MM/yyyy”) give me dd-MM-yyyy?

前端 未结 5 1287
孤街浪徒
孤街浪徒 2020-11-29 19:52

I want my datetime to be converted to a string that is in format \"dd/MM/yyyy\"

Whenever I convert it using DateTime.ToString(\"dd/MM/yyyy\"), I get

5条回答
  •  隐瞒了意图╮
    2020-11-29 20:27

    Pass CultureInfo.InvariantCulture as the second parameter of DateTime, it will return the string as what you want, even a very special format:

    DateTime.Now.ToString("dd|MM|yyyy", CultureInfo.InvariantCulture)
    

    will return: 28|02|2014

提交回复
热议问题