love 10 ways to format time and date using JavaScript and Working with Dates.
Basically, you have three methods and you have to combine the strings for yourself:
Basically, you have three methods and you have to combine the strings for yourself:
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>
0 comments:
Post a Comment