我有这个json_ecoded数据,我无法弄清楚如何转换这个
'firstInvoiceDate' => string '/Date(1363824000000+0000)/' (length=26)
回到
'firstInvoiceDate' => string '3/21/2013'
我已尝试过date()
和strtotime()
,但结果错误。
任何帮助都会受到极大关注。
答案 0 :(得分:0)
您可以使用此功能:
function convertToDate($d, $format = 'm-d-Y') {
// First argument should have format like '/Date(1363824000000+0000)/'
if (!preg_match("/[\d+-]+/", $d, $matches)) return null;
return gmdate($format, $matches[0]/1000);
}
这样称呼:
print convertToDate('/Date(1363824000000+0000)/', 'm-d-Y');
输出:
2013年3月21日