MySQL (Unix 时间戳、日期)转换函数:

  1. unix_timestamp(),
  2. unix_timestamp(date),
  3. from_unixtime(unix_timestamp),
  4. from_unixtime(unix_timestamp,format)
下面是示例:

  1. select unix_timestamp(); — 1218290027
  2. select unix_timestamp(‘2008-08-08’); — 1218124800
  3. select unix_timestamp(‘2008-08-08 12:30:00’); — 1218169800

  4. select from_unixtime(1218290027); — ‘2008-08-09 21:53:47’
  5. select from_unixtime(1218124800); — ‘2008-08-08 00:00:00’
  6. select from_unixtime(1218169800); — ‘2008-08-08 12:30:00’

  7. select from_uixtime(1218169800, ‘%%%%h:%i:%%x’); — ‘2008 8th August 12:30:00 2008’