0

I do an excel export of some data from database.

Date value in database: 2017-02-15 15:31:54 (timestamp)

I set format of excel field like this:

setFormat('dd.mm.yyyy hh:mm:ss')

But the value i get in my excel sheet is 16.02.2017 14:31:54.

Do you have any idea why this happens?

Edit:

If I echo the value of the variable which I insert to excel field, the output is correct. But in excel then there is the wrong value.

Peter Badida
  • 11,310
  • 10
  • 44
  • 90
  • Check something here - http://stackoverflow.com/questions/409286/should-i-use-field-datetime-or-timestamp It seems that TimeStamp is a little different from what you are expecting. – Vityata Feb 15 '17 at 15:01
  • Try casting to a date time format before exporting: SELECT FROM_UNIXTIME(colonne_timestamp) as valeur_datetime FROM table; – Bogdan Feb 15 '17 at 15:51
  • I cast the date before inserting into excel field to `d.m.Y H:i:s`, but I have the same effect, that the day and hour is wrong. – Mr. K. O. Rolling Feb 16 '17 at 07:21
  • edited question – Mr. K. O. Rolling Feb 16 '17 at 07:28
  • I found a solution. The Excel field could not handle the time values in datetime format. I `setType(PHPExcel_Cell_DataType::TYPE_STRING)` of the excel field. Now the value is displayed correctly in excel. – Mr. K. O. Rolling Feb 16 '17 at 08:18

0 Answers0