-3

I am trying to format a date from my database:

$input = $data['date'];
$output = date('d.m.Y', strtotime($input));

The result is:

$input: 2016-02-09 13:42:00

$output: 01.01.1970

I do not understand, I am expecting the $output to be 09.02.2016

Mihriban Minaz
  • 3,043
  • 2
  • 32
  • 52
peace_love
  • 6,229
  • 11
  • 69
  • 157

1 Answers1

0

I found out that I need to write it like this:

$input = new DateTime($data['date']);
$output = $input->format('d.m.Y');
peace_love
  • 6,229
  • 11
  • 69
  • 157
  • 1
    I was about to post it :) http://ideone.com/SSBUno Anyway it could be a language settings issue on the server. – phaberest Feb 09 '16 at 13:02
  • 1
    This makes no sense. The problem was elsewhere. Not sure where the upvotes are coming from – PeeHaa Feb 09 '16 at 14:16