【发布时间】:2019-08-09 09:21:26
【问题描述】:
如何比较像现在时间(10.13 pm)和未来时间(10:15 pm)这样的日期时间值,这两次比较在 if 条件下,这是 true 然后执行任务 else 显示错误
String formattedtime = DateFormat('h:mm a').format(DateTime.now());
//getting Current time is formattedtime
// time is stored in database and comapre with this
if(date==formattedDate &&formattedtime==time &&status =='false'){
}else{
// else condition
}
// remove time condition then working fine
if(date==formattedDate&&status =='false'){
// this condition working Fine but with Time Compare not working
}else{
// else condition
}
不工作
我不知道如何比较这些结果,我只想如果当前时间大于或等于时间(在数据库中)然后执行任务
谢谢
【问题讨论】:
-
所以你有两个
DateTime,你想比较它们吗? -
我将日期时间转换成字符串,然后转换成campare
-
这不是正确的方法@Gnziet
-
这是时间而不是日期,例如(上午 10 点 30 分)和上午 10 点 35 分如何比较字符串值
-
字符串比较是什么意思?为什么要这样比较?