"get date with javascript"
Bootstrap 3.3.0 Snippet by gitdealdo

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="row"> <h2>Create your snippet's HTML, CSS and Javascript in the editor tabs</h2> </div> <button onclick="getDate()" class="btn btn-info">ShowDAte</button> </div>
function getDate(){ var d = new Date(); var month = d.getMonth()+1; var day = d.getDate(); var output = d.getFullYear() + '/' + (month<10 ? '0' : '') + month + '/' + (day<10 ? '0' : '') + day; alert("Hoy es: "+output); return output; } //Method 2 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 yyyy + "/" + (mm[1]?mm:"0"+mm[0]) + "/" + (dd[1]?dd:"0"+dd[0]); // padding }; var date = new Date(); console.log( date.yyyymmdd() ); // Assuming you have an open console //Method 3 function strpad00(s) { s = s + ''; if (s.length === 1) s = '0'+s; return s; } var now = new Date(); var currentDate = now.getFullYear()+ "/" + strpad00(now.getMonth()+1) + "/" + strpad00(now.getDate()); console.log(currentDate );

Related: See More


Questions / Comments: