Convert Date time to specific format in C#

前端 未结 5 1963
野的像风
野的像风 2020-12-30 16:54

I want to convert date time to specify format that is

Wed Aug 01 2012 14:37:50 GMT+0530 (India Standard Time)

Actually i want to display th

5条回答
  •  佛祖请我去吃肉
    2020-12-30 17:32

    You can use date.ToString("format") to do that. Microsoft offer a full reference on how to format your dates the way you want.

    Edit:

    Perhaps there isn't a format ready that exactly matches your format, but you can combine your own based on the format specifiers provided in the above reference.

    // This will output something like Wed Aug 01 2012
    date.ToString("ffffd MMM dd yyyy");
    

    I believe you can follow the same pattern to complete the rest on your own.

提交回复
热议问题