Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

extract month day and year after parsed date d3.js

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.

like image 631
Saurabh Sinha Avatar asked Nov 15 '25 02:11

Saurabh Sinha


1 Answers

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
like image 190
最白目 Avatar answered Nov 17 '25 17:11

最白目



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!