Learn free online HTML5, javascript, and jquery Tutorials by Examples

Thursday 19 June 2014

Displaying the Current Date(2/3/2014 this format) in javascript

-------------------------------------------------------------
<p id="yo"></p>
<script>
var currentDate = new Date();
        var currentday =  currentDate.getDay() + 15;//add days
        var currentmonth = currentDate.getMonth() + 1;//add month
        var currentyear = currentDate.getYear();
        document.getElementById("yo").innerHTML = currentday + '/' + currentmonth + '/' + currentyear;
</script>


------------------------------------------------------------

No comments:

Post a Comment