如何验证日期? [英] How to validate dates?
本文介绍了如何验证日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我在验证两个日期在一起时遇到问题,它们可以正常工作,但是它还允许用户输入小于起始日期"的截止日期",我该如何比较两个日期以确保到日期"大于从日期".
感谢帮助,非常感谢
hi all, im having problems validating two dates together, they work and everything but it also allows the user to enter a "To Date" that is smaller than the "From Date", how can i compare the two dates to ensure that the "To Date" is greater than the "From Date".
help would be appreciated thanks alot
推荐答案
尝试使用 ^ ]
否则尝试这样的事情:
Try with DateTime.Compare Method[^]
Or else try something like this:
string s = "2012-10-01";
string t = "2012-10-16";
DateTime theDateA = DateTime.Parse(s);
DateTime theDateB = DateTime.Parse(t);
if (theDateB > theDateA)
{
// Your code here
}
..and for more look here[^], and also similar threads on CP Search[^]
这篇关于如何验证日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文