string represents date, and reformat it

前端 未结 6 843
情书的邮戳
情书的邮戳 2020-12-21 17:45

The following case: There is a string that has this format \"2012-02-25 07:53:04\"

But in the end, i rather want to end up with this format \"25-02-2012 07:53:04\"

6条回答
  •  旧巷少年郎
    2020-12-21 18:17

    Yes, it is quite possible. All you need to do is use DateTime.Parse to parse the string into a DateTime struct and then use ToString() to write the date back out to another string with the format you want.

提交回复
热议问题