How to change date format from DD/MM/YYYY or MM/DD/YYYY to YYYY-MM-DD?

后端 未结 4 1411

i need to change the format of my date string using C#

from : \"06/16/2010\"or \"16/06/2010\"

to : \"2010-06-16\"

can you please help me achieve this

4条回答
  •  伪装坚强ぢ
    2020-11-30 12:59

    The following will do.

    string datestring = DateTime.Now.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
    

提交回复
热议问题