title: javascript date format yyyy-mm-dd HH:MM:ss
body: <p>I have facing an issue in javascript date format all dates in this format <code>yyyy-mm-dd HH:MM:ss</code></p>
  
  <p>My Code:</p>
  
  <pre><code>var currentdate = new Date();
  var prevdate = new Date();
  var firstdate = new Date();
  
  prevdate.setTime(currentdate.getTime() - (30 * 60 * 1000));
  firstdate.setTime(currentdate.getTime() + (30 * 60 * 1000));
  
  var current = currentdate.toLocaleTimeString(); 
  var previous = prevdate.toLocaleTimeString();      
  var first = firstdate.toLocaleTimeString();      
  </code></pre>
  
  <p>console data</p>
  
  <pre><code>console.log(previous);   //10:28:24 PM
  console.log(current);    //10:58:24 PM
  console.log(first);      //11:28:24 PM
  
  
  </code></pre>
  
  <p>I try this , how can i pass <code>previous</code> and <code>first</code> date</p>
  
  <pre><code>var Currentdate=dateFormat(new Date(), "yyyy-mm-dd HH:MM:ss");
  console.log("Currentdate");  //2020-05-07 22:58:11
  </code></pre>
  
  <p>Expected Output Date Format: <code>yyyy-mm-dd HH:MM:ss</code></p>
  
  <pre><code>previous date: 2020-05-07 22:28:11   // date before 30min
  current date:  2020-05-07 22:58:11   // current date 
  first date:    2020-05-07 23:28:11   // date after 30min
  </code></pre>
  
  <p>What should i do? can anyone help?</p>