Javascript examples for Date Operation:Month
List month name and year for the last 6 months
<html> <head></head> <body> <script> var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; var today = new Date();/*from ww w .jav a 2s. co m*/ var d; var month; for(var i = 6; i > 0; i -= 1) { d = new Date(today.getFullYear(), today.getMonth() - i, 1); month = monthNames[d.getMonth()]; console.log(month); } </script> </body> </html>