title: Javascript - how to set dynamic time interval form UTC time and show content
body: <p>The goal is to show div to inform user for session expirations and offer to extend it before it expired. The session was set through back-end codes on each page load event and saved a cookie value with the next expire time in UTC.</p>
  
  <p>Sample format in UTC Time : MM/dd/yyyy-HH:mm:ss</p>
  
  <pre><code>&lt;div class="session-alert"&gt;
    &lt;p&gt;Your session is going to expire in a while. To keep the current session click "OK"&lt;/p&gt;
    &lt;button class="button button-session-ok"&gt;OK&lt;/button&gt;
    &lt;button class="button button-session-cancel"&gt;OK&lt;/button&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Now I wanted to show session-alert div 20 seconds before the next to expire time using JavaScript. How to convert the next expire time (UTC) to local and subtract 20 seconds form it and pass the time slap into an interval to show session-alert div? I wanted to use only core javascript or jquery no any third party JS or plugin.</p>
  
  <pre><code>var EXPIRE_COUNTDOWN_TIMER;
  
  var nextExprireTime = new Date('05/20/2019-15:23:44');
  var nextExprireTimeISO = nextExprireTime.toISOString();
  var currLocalTime = new Date().toISOString();
  
  var diff = (nextExprireTimeISO - currLocalTime) - 20 seconds;
  
  
  EXPIRE_COUNTDOWN_TIMER = setInterval(function(){
    $('.session-alert').show();
  }, diff);
  </code></pre>