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

前端 未结 5 1294
孤街浪徒
孤街浪徒 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:24

    Slash is a date delimiter, so that will use the current culture date delimiter.

    If you want to hard-code it to always use slash, you can do something like this:

    DateTime.ToString("dd'/'MM'/'yyyy")
    

提交回复
热议问题