Extracting month to day and year after parsing date d3.js

I parsed the date from a json file using a 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 deduce the month, day and year from a date variable and print it. How to do it?

Or you can say that I only need to print the month, day, and year, not additional stuff like Tue (Indian Standard Time) etc.

+3


source to share


1 answer


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

      

+2


source







All Articles