PHP - 将日期转换为简单的日期时间?

时间:2016-10-19 12:56:41

标签: php datetime

我的php客户端正在使用带有日期参数的java soap web服务。客户端以下列格式传递它:

2016-09-18

服务器响应:

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

因为它以简单的日期时间格式表示:

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

如何在php中将其转换为简单的日期时间格式?

1 个答案:

答案 0 :(得分:0)

回音日期(' c',strtotime(' 2016-10-18'));

返回

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

这是ISO 8601的日期,可能是可以接受的。

或者在转换为http://php.net/manual/en/function.date.php之后转换为字符串时转换您自己的日期格式。