从日期/时间字符串中删除时间 [英] Remove time from a date/time string

查看:183
本文介绍了从日期/时间字符串中删除时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的日期和时间存储在我的数据库中,我不想同时显示,只是日期本身。当我将日期/时间存储在变量中时,如何仅在C#中输出日期?

解决方案

这非常有用:



http:// www .csharp-examples.net / string-format-datetime /



在你的情况下,我会说:

  DateTime dt = new DateTime(2008,3,9,16,5,7,123); 
String.Format({0:MM / dd / yy},dt);


I have date and time stored in my database and I don't want to display both, just the date itself. When I store the date/time in a variable how do I output just the date in C#?

解决方案

This is very useful:

http://www.csharp-examples.net/string-format-datetime/

In you case I would say:

DateTime dt = new DateTime(2008, 3, 9, 16, 5, 7, 123);
String.Format("{0:MM/dd/yy}", dt);  

这篇关于从日期/时间字符串中删除时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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