Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have an xml file that stores subscription data. and a report form that shows the details of the subscription. I am trying to format the date in this style 01/01/2013 but when I try to display the date it does not show the correct value I get 00/01/2013.

Here is the code that displays the date.
C#
label6.Text = "Start Date: " + user.StartDate.ToString("mm/dd/yyyy");

And this is what it looks like in the xml.
HTML
<StartDate>2013-01-20T00:00:00</StartDate>

And in my model I have....
C#
public DateTime StartDate { get; set; }


Thanks in advance.
Posted

1 solution

It';s not odd at all - it is exactly what you asked for: minutes/day/year.
If you want the month on the other hand:
C#
user.StartDate.ToString("MM/dd/yyyy");
Would probably be what you wanted.
 
Share this answer
 
Comments
David C# Hobbyist. 24-Dec-12 7:39am    
Thank You, Nothing like a rookie mistake.
OriginalGriff 24-Dec-12 7:45am    
You're welcome - we all do it! :laugh:
CPallini 24-Dec-12 7:58am    
Nope it is the .NET Framework going opposite to the gold tradition:
http://www.cplusplus.com/reference/ctime/strftime/
:-)
Sergey Alexandrovich Kryukov 24-Dec-12 13:00pm    
Sure, a 5.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900