title: How to format a date (randomly generated within a period) to DD/MM/YYYY
body: <p>I am using below function to get randomize date.
  I am getting date in MM/DD/YYYY format ,
  Can anyone help me in how can i get date in DD/MM/YYYY format.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function randomDate(date1, date2) {
    function randomValueBetween(min, max) {
      return Math.random() * (max - min) + min;
    }
    var date1 = date1 || '01-01-1970'
    var date2 = date2 || new Date().toLocaleDateString()
    date1 = new Date(date1).getTime()
    date2 = new Date(date2).getTime()
    if (date1 &gt; date2) {
      return new Date(randomValueBetween(date2, date1)).toLocaleDateString()
    } else {
      return new Date(randomValueBetween(date1, date2)).toLocaleDateString()
  
    }
  }
  var date = randomDate('02/13/2020', '01/01/2018');
  
  console.log(date)</code></pre>
  </div>
  </div>
  </p>