I have a date variable, stored as a String in the 'YYYY-mm-dd' format. What is the best way to check, if that date has not already passed?
我有一个日期变量,以“YYYY-mm-dd”格式存储为字符串。如果那个日期还没有过,最好的检查方法是什么?
2 个解决方案
#1
65
Date.parse('2010-11-01') < Date.today
will return true if '2010-11-01' has already passed
如果“2010-11-01”已经通过,会返回true吗
#2
57
You can also use past?
你也可以用过去吗?
Date.parse("2012-11-01").past?
#1
65
Date.parse('2010-11-01') < Date.today
will return true if '2010-11-01' has already passed
如果“2010-11-01”已经通过,会返回true吗
#2
57
You can also use past?
你也可以用过去吗?
Date.parse("2012-11-01").past?