PHP Date comparison issue -
i trying see if date between first , last of current month. have tried convert following $dateinfo string date, can compare values... how can accomplish this? dateinfo has in format below.
variables:
$dateinfo = '20150624t14:49:59' $dfirst = new datetime('first day of month'); $dlast = new datetime('last day of month');
the comparison:
if(($dateinfo >= $dfirst) && ( $dateinfo<= $dlast )){ echo 'something';} }
try using datetime object:
<?php $dateinfo = new datetime('20150724t14:49:59'); $dfirst = new datetime('first day of month'); $dlast = new datetime('last day of month'); if (($dateinfo >= $dfirst) && ($dateinfo <= $dlast)) { $string = "%s between %s , %s"; printf($string, $dateinfo->format('d/m/y'), $dfirst->format('d/m/y'), $dlast->format('d/m/y')); }
Comments
Post a Comment