Skip to content

Instantly share code, notes, and snippets.

@omalave
Last active April 16, 2016 18:07
Show Gist options
  • Save omalave/889de805073939907cd60a49d48f5988 to your computer and use it in GitHub Desktop.
Save omalave/889de805073939907cd60a49d48f5988 to your computer and use it in GitHub Desktop.
fill a input field with current date
$(document).ready(function(){
var fullDate = new Date();
var twoDigitMonth = (fullDate.getMonth()+1)+"";if(twoDigitMonth.length==1) twoDigitMonth="0" +twoDigitMonth;
var twoDigitDate = fullDate.getDate()+"";if(twoDigitDate.length==1) twoDigitDate="0" +twoDigitDate;
var currentDate = twoDigitDate + "/" + twoDigitMonth + "/" + fullDate.getFullYear();
$("#datepicker").val(currentDate);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment