Convert Date time to specific format in C#

前端 未结 5 1949
野的像风
野的像风 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条回答
  •  萌比男神i
    2020-12-30 17:46

    There's no reason with the information already provided that you can't work this out for yourself, but to get a string reading:

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

    Then what you want is to get the date and time in the correct form (the "Wed Aug 01 2012 14:37:50" bit) with "GMT+0530 (India Standard Time)" added on the end. Assuming that that bit is always the same of course.

    So the code you'd need is:

    string string_name = (date.ToString("ffffd MMM dd yyyy HH:mm:ss") + "GMT+0530 \(India Standard Time\)");
    //string_name will be in the form "Wed Aug 01 2012 14:37:50 GMT+0530 (India Standard Time)"
    

    But, as I said, that's something you should be able to work out yourself using the references provided.

提交回复
热议问题