我想使用Facebook graph API获取用户DOB信息。我得到了完整的 dob,但我只需要日和月
$graph_url ="https://graph.facebook.com/me?fields=id,first_name,name,gender,location,birthday&access_token=" . $accessToken;
$user = json_decode(get_html($graph_url));
echo $user->birthday
输出MM/DD/YYYY
以任何方式仅获取月和日。 谢谢。
正如你所说,你想要像8/5
这样的数字从你的生日开始。所以你必须简单地做:-
echo date('m/d',strtotime( $user->birthday));
要检查日期格式:-
http://php.net/manual/en/function.date.php