Skip to content

Instantly share code, notes, and snippets.

@brunomonteiro3
Created November 7, 2016 13:38
Show Gist options
  • Save brunomonteiro3/687bf5ff5a9425247a7be7e709fb5f94 to your computer and use it in GitHub Desktop.
Save brunomonteiro3/687bf5ff5a9425247a7be7e709fb5f94 to your computer and use it in GitHub Desktop.
Current date in pure JS + jQuery
$(document).ready(function(){
var today = new Date();
var day = today.getDate();
var month = today.getMonth()+1; //January is 0!
var year = today.getFullYear();
if(day < 10) {
day = '0' + day
}
if(month < 10) {
month = '0'+ month
}
today = year + '-' + month + '-' + day;
$('.joined_at').val(today);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment