Created
November 7, 2016 13:38
-
-
Save brunomonteiro3/687bf5ff5a9425247a7be7e709fb5f94 to your computer and use it in GitHub Desktop.
Current date in pure JS + jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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