Posted By

Wookkie on 08/26/11


Tagged

date


Versions (?)

edit Dateformat to yyyy-mm-dd


 / Published in: JavaScript
 

  1. var date = new Date();
  2. var d = date.getDate();
  3. var day = (d < 10) ? '0' + d : d;
  4. var m = date.getMonth() + 1;
  5. var month = (m < 10) ? '0' + m : m;
  6. var yy = date.getYear();
  7. var year = (yy < 1000) ? yy + 1900 : yy;
  8.  
  9. document.write(day + "/" + month + "/" + year);

Report this snippet  

You need to login to post a comment.