I cant get the month and day from the date object like this : “2009/12/30”
The error which gives in the console is: TypeError: created_at.getMonth is not a function
function search(){
var value = $('#box').val();
var array=[];
var dateArray = [];
var datesString;
if (value!==""){$.getJSON("http://search.twitter.com/search.json?callback=?&q=value&rpp=5",
function(data){
$.each(data.results, function(i, item){
var user=item.from_user;
var created_at=item.created_at;
var n=created_at.toString();
var month=n.getMonth();
var day = n.getDate();
var year = n.getFullYear();
var created=month+day+year;
array.push({date:created,username:user});
});
Anyone knows what the problem is?
thanks!
JSON doesn’t support
Datevalues directly, so Twitter is serializing eachcreated_atvalue as aStringthat you’ll first have to parse:Then, you can use
Datemethods to get information from it:Also, if
createdis intended to be aDateat midnight, try this instead: