1
I am creating a validation class and I have a method to validate dates.
When will I validate based on now
, strtotime calculates including time.
$v->rule( '07/28/2014' , 'before.2014' )
this rule validates only the year
$v->rule( '07/28/2014' , 'before.now' )
this rule validates the M.D.Y date
For the first case the comparison is:
strtotime( '2014' ) < strtotime( '2014' )
For the second case the comparison is:
strtotime( '07/28/2014' ) < strtotime( '07/28/2014 17:59:46' )
The result is a false
and another true
.
I might add H:i:s
when comparing 07/28/2014, or using strtotime( date( 'm/d/Y' ) )
or another alternative to now
.
In PHP you have the warning, about the now
, but here the time is normal
In PHP 5 higher than 5.0.2, "now" and other relative time are erroneously computed for midnight of the day. Different from other versions where it is correctly computed from the current time.
A
now
only inY-m-d
I believe it is ideal. Another detail, avoidstrtotime
, use datetime whenever possible. http://answall.com/a/26749/4751– gmsantos