奇怪的行为DateTime.ToString(" mm / dd / yyyy"); [英] Odd behaviour DateTime.ToString("mm/dd/yyyy");

查看:154
本文介绍了奇怪的行为DateTime.ToString(" mm / dd / yyyy");的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储订阅数据的xml文件。以及显示订阅详情的报告表单。我试图以这种风格格式化日期01/01/2013但是当我尝试显示日期时它没有显示正确的值我得到00/01/2013。



这是显示日期的代码。

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.

label6.Text = "Start Date: " + user.StartDate.ToString("mm/dd/yyyy");



这就是它在xml中的样子。 />


And this is what it looks like in the xml.

<StartDate>2013-01-20T00:00:00</StartDate>



在我的模特中我有....


And in my model I have....

public DateTime StartDate { get; set; }





提前谢谢。



Thanks in advance.

推荐答案

它's; s完全没有奇怪 - 这正是你要求的:分钟/天/年。

如果你想要月份另一方面:

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:
user.StartDate.ToString("MM/dd/yyyy");

可能是你想要的。


这篇关于奇怪的行为DateTime.ToString(&quot; mm / dd / yyyy&quot;);的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆