如何保存日期时间没有时间吗? [英] How to save Date Time without the time?
本文介绍了如何保存日期时间没有时间吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将如何保存日期时间,没有时间或最好12:00时间戳,无论时间是在那一刻是什么?
How would i save the date time, with no time or preferably with a time stamp of 12:00, no matter what the time is at that moment?
我不想使用的ToString(DD / MM / YYYY);
,因为它会打开一个一大堆新的可能的误差
I dont want to use .ToString("dd/MM/yyyy");
, because it will open up a whole lot of new possible errors.
推荐答案
的DateTime
结构有一个日期
物业应该满足您的需求:
DateTime
struct has a Date
property that should serve your needs:
DateTime dateOnly = dateTime.Date;
当然,它仍然会不可避免地包含时间的一部分,但你应该能够忽略它。
Of course, it'll still inevitably contain a time part but you should be able to ignore it.
这篇关于如何保存日期时间没有时间吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文