问题描述:

My php client is consuming java soap web service with date parameter. The client is passing it in the following format:

2016-09-18

The server responds with:

javax.xml.bind.UnmarshalException: java.time.format.DateTimeParseException: Text '2016-09-18' could not be parsed at index 10

as it expcts it in simple datetime format:

2016-09-18T00:00:00.000-0000

How can I convert it to simple datetime format in php ?

网友答案:

echo date('c', strtotime('2016-10-18'));

returns

2016-10-18T00:00:00-04:00

which is the ISO 8601 date, and might be acceptable.

Or roll your own date format after converting string-to-time, as in http://php.net/manual/en/function.date.php.

相关阅读:
Top