RandomAPI / Randomuser.me-old-source

[Deprecated] PHP source for Random User Generator - Please take a look at the new Node version
https://randomuser.me
137 stars 48 forks source link

Birthdays all the same month. #44

Closed odesey closed 9 years ago

odesey commented 9 years ago

I requested 200 random users and all the user birth days are in January 1970. Is this a bug or by design?

keitharm commented 9 years ago

What URL and parameters are you calling?

When I call the api at http://api.randomuser.me/?results=200, the birthdays are all randomized as designed.

odesey commented 9 years ago

I ran the following:

var randomUser = HTTP.get("http://api.randomuser.me/?results=200&nat=us", {params:{dataType: 'json'}}, function(error, result){ console.log(error); console.log(result); randomUser = result; })

Then: moment(randomUser.data.results[99].user.dob).format("MM-DD")

And all the user months come back in Jan.

keitharm commented 9 years ago

You will need to use the unix method on the timestamp in order for Moment.js to work with it. Try this out

moment.unix(randomUser.data.results[99].user.dob).format("MM-DD")

Check this out for more info: http://momentjs.com/docs/#/parsing/unix-timestamp/

odesey commented 9 years ago

Worked! Thanks for the help.

keitharm commented 9 years ago

No problem! :)