-2

Hi Im trying to get the string "25.01.2017 08:22:10" to a valid php time

date_default_timezone_set('Europe/Berlin');
$format = 'Y-m-d H:i:s';
$date = DateTime::createFromFormat($format, 25.01.2017 08:22:10);

does not work. Maybe its because of the dots...

Fabian Tschullik
  • 95
  • 1
  • 2
  • 9

1 Answers1

0

Try this:

date_default_timezone_set('Europe/Berlin');

$date = DateTime::createFromFormat(
    'd.m.Y H:i:s', 
    '25.01.2017 08:22:10'
);

Note Adjusted the date format and surrounded the date with ' (it needs to be a string).

For reference, see:

localheinz
  • 9,179
  • 2
  • 33
  • 44