Convert string to specific DateTime format

前端 未结 5 1615
既然无缘
既然无缘 2021-01-07 01:17

I\'ve been googling for a while now and for the life of me can\'t seem to find a solution. I thought this would be easy but it\'s taking too long and am turning to stackover

5条回答
  •  滥情空心
    2021-01-07 02:05

    Here is example for this.

        String strDate="12/20/2013";
        string strFormat="dd/MM/yyyy";
        DateTime objDT;
    
        if (DateTime.TryParseExact(strDate, strFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out objDT) == true)
        {
            Response.Write("Formatted DateTime : " + objDT.ToString());
        }
        else
        {
            Response.Write("Not able to parse datetime.");
        }
    

提交回复
热议问题