<?php
/**
 * @package  Themeprice Updater
 */
namespace Inc\Plugupdate;


class Plugtimecheck {

    public $returntimethemeprice;

    function __construct(){

        if (is_admin()) {

       $tokenthemeprice  =  get_option('themepricestatus');


            if($tokenthemeprice != NULL){
                $retuenvalue = 0;

        $themeprice = get_option( 'themepriceupdaterstatus');
      
        $current_time = date('H:i:s');
        $statusthemepriceupdater = get_option( 'themepriceupdaterstatus');
        $diff = round((strtotime($statusthemepriceupdater) - strtotime($current_time)) / 60,2);

        if ($diff <= 59 && $diff > 56) {
            $retuenvalue = 1;
            $this->returntimethemeprice = $retuenvalue;
        }
            else{
                $retuenvalue = 0 ;
                $this->returntimethemeprice = $retuenvalue;
            }
                if ( $retuenvalue == 0) {
                    if ($diff < 1 || $diff > 61) {
                         $endTime = strtotime("+59 minutes", strtotime($current_time));
                         $finaltime = date('H:i:s', $endTime);
                         update_option( 'themepriceupdaterstatus', $finaltime, true );
                    }
                }
         }
      }
  }

}