I am calling a webservice which return me back a json object. The json object encodes the date. I am trying to find a way to convert that date to m-d-Y format in php. Json
If there's a chance you said 02-15-1982 but really meant 04-12-1982, then I have a solution. If not, then there's a gap in the time of about 60 days, which can be accounted for with a bit more math.
Here's my solution for now:
date_default_timezone_set( 'America/Denver' );
$json = json_decode( '{"DateOfBirth":"\/Date(387518400000-0400)\/"}' );
$date_string = $json -> DateOfBirth;
preg_match( '/([\d]{9})/', $date_string, $matches ); // gets just the first 9 digits in that string
echo date( 'm-d-Y', $matches[0] );
This returns: 04-12-1982