I have a dataset and each has a time stamp for when it was created in this exact format e.g.
[ {"Name": "Jake", "created":"2013-03-01T19:54:24Z" },
{"Name": "Rock", "created":"2012-03-01T19:54:24Z" } ]
As a result I wish to use 'created' within a function which calculates that if the data was entered 60days or less from today it will appear in italic. However, the function I've attempted has no affect. I'm attempting to do the calculations all in milliseconds:
node.append("text")
.text(function(d) { return d.Name; })
.style("font", function (d)
{ var ja = Date.parse(d.created);
var time = new Date ();
var n = time.getTime();
if(ja > (n - 5184000)) {return "Arial 10px bold";}
else {return "Arial 11px";}
})
.text(function(d) { return d.Name; });
I have also tried to replace var ja with:
var iso = d3.time.format.utc("%Y-%m-%dT%H:%M:%S.%LZ").parse(d.created)
I am curious whether I am actually converting the data at all into milliseconds. Or if my formatting is completely wrong! As my text doesnt change at all... Even when I change the font size, it doesnt change. So I'm a bit confused.
Thanks in advance