I want to display a date stamp on my view. The format I want is "20120712" for 07/12/2012.
Here is what I have so far,
$(function () {
$(document).ready(function () {
var now = new Date();
var nowYear = now.getFullYear();
var nowMonth = now.getMonth() + 1;
var nowDate = now.getDate();
var DateStamp = nowYear.toString() + nowMonth.toString() + nowDate.toString();
$("#DateStamp").val(DateStamp);
});
I am able to display: "2012712" but I want to display leading zeros for month and date for single digit months and dates, e.g. "20120712"