MySQL - bigints和php

How do I cope with a bigint (milliseconds since 1970) got from a mysql table, when the max int size in php is a lot lower than this for current dates and times.

You can either

  1. Divide by 1000 and use a float (with optional use of arbitrary precision maths functions to do any calculation on them (outside of <, = or >))
  2. Store as a string (and not do any calculations)
  3. Upgrade to a 64-bit OS and re-install PHP (much larger MAXINT value)

PHP's max int size is plenty big on a 64 bit architecture. What are you running it on? Other ideas include:

  1. Divide result by 1000 and cast to integer in MySQL, eg, SELECT CAST(ts/1000 AS INT) AS ts
  2. Convert to a float when received in PHP (less accuracy)