Get date using javascript in this format [MM/DD/YY] -
How can I use JavaScript [mm / dd / yy] in this format? I am struggling to get the 'year' figure of 2 points as opposed to the whole issue.
Thanks!
Try it out:
HTML
& Lt; Div id = "output" & gt; & Lt; / Div & gt; JS >
(function () {// Get current date var date = new date (); // format day / month / year to Two digits variedrate = ('0' + date .getDate ()). Piece (-2); var formattedmont = ('0' + (date .getMonth (+ 1)). Piece (-2); var formatted year = Date.getFullYear (.) ToString (). Substr (2,2); // Combination and Format Date String var dateString = formattedMonth + '/' + formattedDate + '/' + formattedYear; // Reference output DIV var output = Document .querySelector ('#output'); // output datestring output. Wiener html = datestring;}); Object:
Comments
Post a Comment