Skip to content

Instantly share code, notes, and snippets.

@Ruekompa
Last active August 29, 2015 14:00
Show Gist options
  • Save Ruekompa/11063353 to your computer and use it in GitHub Desktop.
Save Ruekompa/11063353 to your computer and use it in GitHub Desktop.
Javascript for mm/dd/yyyy format
<script type="text/javascript">
Date.prototype.yyyymmdd = function() {
var yyyy = this.getFullYear().toString();
var mm = (this.getMonth()+1).toString(); // getMonth() is zero-based
var dd = this.getDate().toString();
return (mm[1]?mm:"0"+mm[0]) + '/' + (dd[1]?dd:"0"+dd[0]) + '/' + yyyy;
};
d = new Date();
$('#today').html(d.yyyymmdd());
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment