Saturday 1 February 2014

Where can I find documentation on formatting a date in JavaScript

 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:
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>

share|improve this answer

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More