Leading Zero Date Format C#

后端 未结 3 638
攒了一身酷
攒了一身酷 2020-12-11 14:45

I have this function...

private string dateConvert(string datDate)
{
        System.Globalization.CultureInfo cultEnGb = new System.Globalization.CultureInfo         


        
相关标签:
3条回答
  • 2020-12-11 15:34

    Can't you use the string.Format after you've done the conversion?

    ie return string.Format("{0:d}", datDate);

    0 讨论(0)
  • 2020-12-11 15:35

    I would recommend using the latest C# shorthand (format specifier) for usability and readability's sake:

    return dateTimeValue:MM-dd-yyyy;
    

    Clean and concise.

    0 讨论(0)
  • 2020-12-11 15:48
    return dateTimeValue.ToString("MM-dd-yyyy");
    
    0 讨论(0)
提交回复
热议问题