convert a date in a text box into a (dd/mm/yy) format - Javascript Date Operation

Javascript examples for Date Operation:Date Convert

Description

convert a date in a text box into a (dd/mm/yy) format

Demo Code

ResultView the demo in separate window

<!doctype html>
<html>
   <head></head>
   <body style="font-family: monospace"> 
      <ol id="stdout"></ol> 
      <script>
  var data = ["09/06/2018", "25/06/2018", "22/06/2018", "25/07/2018", "18/05/2018"];
data.sort(function(a,b) {
  a = a.split('/').reverse().join('');
  b = b.split('/').reverse().join('');
  return a > b ? 1 : a < b ? -1 : 0;
});/*from w  w w  .  ja  v  a 2s  .  c  o m*/
for(var i=0; i<data.length; i++)
   stdout.innerHTML += '<li>' + data[i];

      </script>  
   </body>
</html>

Related Tutorials