DateTime ToString(“dd/MM/yyyy”) returns dd.MM.yyyy

前端 未结 4 2080
刺人心
刺人心 2020-12-25 08:12

I have also tried shielding the \'/\' symbol in the formatting string, but it didn\'t quite work. My final goal is to get the date with the \'/\' symbols as separators. I g

4条回答
  •  不知归路
    2020-12-25 08:31

    This works (note the InvariantCulture):

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

    If a CultureInfo is not specified, the CurrentCulture will be used. If this is a culture that doesn't use slashes as separators in dates it is replaced by whatever the actual culture date separator is.

提交回复
热议问题