title: Php subtract time saved in session with current time
body: <p>i am using jquery countdown timer but the problem is that timer start from value set every time on page refresh . I want to get time on first time and Save in PHP Session and subtract second time from frist time and update session etc. In Simple Word i want to create php countdown timer run only 50 using php </p>
  
  <p>here is my controller code</p>
  
  <pre><code>public function actionViewtimer($id) {
      $session = Yii::app()-&gt;session;
      $this-&gt;layout = 'countdownlayout';
      if (empty($session['countdowntime'])) {
          $orderTime = microtime(true); #when user first time enter timer start from 50 mins
          $session-&gt;add('countdowntime', array($orderTime));   //replace this line
      } else {
          $time_end = microtime(true);
          $orderTime = $time_end - $time_start;
          unset($session['countdowntime']);//unset old session
          $session-&gt;add('countdowntime', array($orderTime));   //when user enter second  
      }
  
      $getMinutes = $getMinutes_from_orderTime ; #please tell me how  we extact minutes and pass them to view
  
      $session-&gt;add('timersession', array($rand));   
      $this-&gt;render('viewtimerpage', array(
          'getMinutes' =&gt; $getMinutes
      ));
  }
  </code></pre>
  
  <p>here is my jquery code </p>
  
  <pre><code> &lt;script&gt;
   $(function() {
       $('#xlarge').countdowntimer({
            minutes: 50&lt;?php echo $getMinutes; ?&gt;,
            size: "lg",
            timeUp: timeisUp
       });
   });
  
   function timeisUp() {
       alert('Time Complete');
       return false;
   }
   &lt;/script&gt;
  </code></pre>