Friday, 4 January 2019

PHP Time Comparison Is Failing

I'm working on a Wordpress plugin and having problems with a time comparison. I basically want: if selected time is before current time, do the thing... but it's not working.

The validation is failing if expire is less than five hours ahead of the time(). I correct this by adding the gmt offset expire but then it still fails. Any ideas?

    if(validateDate($_POST['expire'])){
    $expires_epoch = (strtotime($_POST['expire']) - (get_option( 'gmt_offset' ) * HOUR_IN_SECONDS));
if($expires_epoch < time()){...do the thing...

Any thoughts? It seems simple but it doesn't seem to be working the way I'd like it to.



from PHP Time Comparison Is Failing

No comments:

Post a Comment