将datetime转换为yyyy / MM / dd格式。 [英] converting datetime to yyyy/MM/dd format.

查看:96
本文介绍了将datetime转换为yyyy / MM / dd格式。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[荒谬]



大家好,

i想转换datetime.now格式化yyyy / MM / dd但转换后的格式也应该是在datetime,不在字符串。这是我不想要string.format方法,因为它会将datetime作为string.i想要返回datetime.Any help?

[Absurdity]

Hello everyone,
i want to convert datetime.now to format yyyy/MM/dd but the converted format should also be in datetime,not in string.that is i dont want string.format method as it will return datetime as string.i want as datetime.Any help?

推荐答案

你好,



这样写的



Hi,

Write like this

string dtime = DateTime.Now.ToString("yyyy/MM/dd");



你肯定会得到你想要的日期格式。


you'll sure get your desire date format.


我一直想知道这些问题是:



如果有人学习C#,他/她如何错过MSDN网站?只需在任何框架元素上按VisualStudio中的F1即可访问.NET文档 - 它会为您带来(上下文相关的)文档:



所以有一个看看 http://msdn.microsoft.com/en -us / library / system.string.format(v = vs.80).aspx [ ^ ]用于字符串格式化。



在询问之前进一步的问题 - 不是你不能在这里得到答案(如你所见) - 我认为你会更快地得到你的答案,并通过阅读文档了解更多。如果有什么不清楚的地方 - 这会成为一个好问题......
What I always wonder about such questions is:

If someone learns C# how can he/she miss the MSDN site? The .NET docu can be reached by just pressing F1 in VisualStudio on any framework element - and it brings you (context-sensitive) to the documentation:

So have a look at http://msdn.microsoft.com/en-us/library/system.string.format(v=vs.80).aspx[^] for string formatting.

before asking further questions of this kind - not that you can't get the answer here (as you see) - I think you will get your answer faster and learn more by reading the documentation. If something there is unclear - that would make a good question...


这篇关于将datetime转换为yyyy / MM / dd格式。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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