Reputation: 1800
I parsed the date from json file with the function in d3.js:
var parseDate = d3.time.format("%m-%Y").parse;
and get the date as:
var date = "Tue Jan 01 2013 00:00:00 GMT+0530 (India Standard Time)"
Now I want to take out the month, day, and year from the variable date and print it. How do I do that?
Or you can say I need to print only month, day, and year, not the extra stuff like Tue (India standard time) etc.
Upvotes: 4
Views: 11160
Reputation: 3644
edit: Assuming you mean a javascript date object:
var date = new Date("Tue Jan 01 2013 00:00:00 GMT+0530 (India Standard Time)");
var day = date.getDay(); //returns 0 - 6
var month = date.getMonth(); //returns 0 - 11
var year = date.getFullYear(); //returns 4 digit year ex: 2000
Upvotes: 11