Datetime format in C#
I have 开发者_开发百科a DateTime
saved in dtmNextPayment
. I want that to showed in the label in mm/dd/yyyy way. I have tried using
lbltakeeffectdate.Text = dtmNextPayment.ToString("mm/dd/yyyy");
But month is always shown as 00. I have no idea why? Please let me know what should be the problem..
And also, please tell me what is the best solution.. Thank you so much!!
Month is "MM". "mm" is minutes.
Full list of available custom datetime formats (along with examples) is here: http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
You need to use MM. Capital M is month, little m is minutes
lbltakeeffectdate.Text = dtmNextPayment.ToString("MM/dd/yyyy")
List of Format Options
精彩评论