I’m trying to convert from JSON string to PHP a DOB and it works but gives me the wrong DOB.
$url = "test.js";
$content = file_get_contents($url);
$json = json_decode($content, true);
$DOB = date('m/d/Y', preg_replace('/[^\d]/','', $json['Player'][BirthDt])/1000);
what get JSONJason is :
"BirthDt":"\/Date(-388094400000)\/"
in PHP i get this:04/19/1982 instead of 09/14/1957
any ideas???
Your regular expression is removing the negative sign, so it’s becoming a date after the unix epoch (Jan 1st 1970), instead of before. Try something like this:
You can see it working in the demo.