Formatting a date in JavaScript
by THavamani[ Edit ] 2013-08-08 14:26:48
Javascript Date functions:
getDate(): Returns the date
getMonth(): Returns the month
getFullYear(): Returns the year
Example:
<script type="text/javascript">
var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth() + 1; //Months are zero based
var curr_year = d.getFullYear();
document.write(curr_date + "-" + curr_month + "-" + curr_year);
</script>