0

I need to create a column of seconds calculated from an already existing column of timestamp called 'time'. I tried with a query with unix_timestamp but it doesn't accept a thing like:

UPDATE tempLog SET seconds= UNIX_TIMESTAMP('time')

I'm a beginner in stackoverflow and mysql, thanks.

Barmar
  • 741,623
  • 53
  • 500
  • 612
  • Don't put `time` in quotes, just `UNIX_TIMESTAMP(time)`. – Barmar Feb 16 '16 at 18:47
  • thks Barmar, it worked with UNIX_TIMESTAMP(time). But I finally chose to do it with php strtotime because the above method weirdly changed the hour, min and sec of the column timestamp. But it is solved. – Devernay Stéphane Feb 16 '16 at 20:50
  • `UNIX_TIMESTAMP` is based on GMT, not local time. So it could change the hour, but shouldn't change minutes and seconds (unless you're in one of the partial-hour timezones). – Barmar Feb 16 '16 at 21:12

0 Answers0