匹配时间HH:MM,但默认情况下它们匹配HH:MM; SS [英] matching time HH:MM but bydefault they are matching HH:MM;SS
问题描述
我在asp.net中工作.
if(DateTime.Now< = MailTime)//复制条件,其中MailTime = 7:00 pm在窗口配置中使用.在复制中使用
我只希望以分钟为单位匹配时间,但默认情况下系统匹配HH:MM:SS并以其他方式(如果要输入if循环,请返回else)
请帮助我
i m working in asp.net.
if (DateTime.Now <= MailTime) //condition in apllication taken where MailTime =7:00 pm taken in window configuration.using in apllication
i want only match time in minute but by default system are matching HH:MM:SS and return to else at any how i want to enter in if loop
pls help me
推荐答案
尝试一下
Try This
DateTime d = DateTime.Parse((DateTime.Now.ToString("hh:mm")));
if (d <= MailTime)
{
Response.Write("yes");
}
Convert.ToDateTime(DateTime.Now.ToString("hh:mm"))
首先,获取分钟和小时,然后转换为DateTime对象,然后与其他datetime对象进行比较.您可以通过多种方式来执行此操作,这只是一个示例.
First, get just the minute and hours and then convert to a DateTime object and then compare to your other datetime object. There are lots of ways you can do this, this is just one example.
这篇关于匹配时间HH:MM,但默认情况下它们匹配HH:MM; SS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!