Posted By

vagrantradio on 06/28/11


Tagged

date


Versions (?)

JavaScript Date Formatting


 / Published in: JavaScript
 

  1. var currentTime = new Date()
  2. var month = ("0" + (currentTime.getMonth() + 1)).slice(-2)
  3. var day = currentTime.getDate()
  4. var year = currentTime.getFullYear()
  5. //insert into form
  6. var frm = document.getElementById('contact-form');
  7. frm.dater.value = (year + "-" + month + "-" + day)

Report this snippet  

You need to login to post a comment.