I'm creating a validation class and I have a method to validate dates.
When I am going to validate based on now
, strtotime calculates including hour.
$v->rule( '07/28/2014' , 'before.2014' )
this rule only validates the year
$v->rule( '07/28/2014' , 'before.now' )
this rule validates the date M.D.Y
For the 1st case the comparison is:% strtotime( '2014' ) < strtotime( '2014' )
For the 2nd case the comparison is:% strtotime( '07/28/2014' ) < strtotime( '07/28/2014 17:59:46' )
The result is false
and true
.
I should add H:i:s
when comparing 07/28/2014, or use strtotime( date( 'm/d/Y' ) )
or other alternative to now
.
In PHP you have the warning, about now
, but here the time is normal
In PHP 5 higher than 5.0.2, "now" and other relative times are erroneously computed for midnight of the day. Unlike other versions where it is correctly computed from the current time.