如何从日期中删除时间 [英] How to reomve time from date
本文介绍了如何从日期中删除时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
谁能帮我删除使用asp.net标签中的时间02-02-2012 00:00:00 .
在此先感谢.
Hi
Can any one help me how to remove the time 02-02-2012 00:00:00 which is in label using asp.net.
Thanks in Advance.
推荐答案
浏览以下链接以获取不同的日期格式
http://www.csharp-examples.net/string-format-datetime/ [ ^ ]
http://www.dotnetperls.com/datetime-format [
Go through the below links for different date formats
http://www.csharp-examples.net/string-format-datetime/[^]
http://www.dotnetperls.com/datetime-format[^]
Thanks
--RA
您不应删除",而应正确格式化"(请参阅 [ ^ ]):
You shouldn''t ''remove'', you should instead ''properly format'' (see "Standard Date and Time Format Strings"[^]):
myLabel.Text = myDate.ToString("d");
只需将其添加到代码中
(在标签中说您想今天的日期)
Just add this to the code
(let say you want today''s date in the Label)
DateTime dtm = DateTime.Now;
Label_Id.text= dtm.ToString("dd/MM/yyyy");
希望对您有所帮助.
谢谢!!
Hope it help.
Thanks!!
这篇关于如何从日期中删除时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文