title: How to convert date into this 'yyyy-MM-dd' format in angular 2
body: <p>I want to convert current data into <code>'yyyy-MM-dd'</code> format in .ts file. i template it can easily be done by using data pipe. how to do that in typescript.</p>
  
  <p><strong>In template:</strong></p>
  
  <pre><code>{{date  | date:'yyyy-MM-dd'}}
  </code></pre>
  
  <p><strong>How to convert in this format <code>'yyyy-MM-dd'</code> in typescript</strong>.</p>
  
  <p>now i am just getting current date by using this.</p>
  
  <pre><code>this.date =  new Date();
  </code></pre>
  
  <p>but need to convert it into given format.
  Please guide how to do that... Thanks!</p>