Why is my Datetime field not saved?
The above code is correct, date time was saved into DB.
the problem is frontend.

frontend expected this format:

"2016-08-01T12:30:00", need a "T" as separator.


here is how to put that T as separator,

\DateTime::format("Y-m-d\Th:i:s"), need a escape character in-front of T.


2016-01-22 update:

By the way, I have found out in Drupal 8 , correct way to store datetime is follow:

1&gt; first , find out current user timezone, \Drupal::currentUser()-&gt;getTimezone()

2&gt; $given = new \Drupal\Core\Datetime\DrupalDateTime("2016-08-01T12:30:00",$user-&gt;getTimezone());

3&gt; $given-&gt;setTimezone(new \DateTimeZone("UTC"));

4&gt; then get back formated datetime string $given-&gt;format("Y-m-d\Th:i:s");