0

From an external website I receive, amongst other data, a date/time stamp like this 1346729259806 or 1346734102948 I have been trying to see what the best way to convert this into a formatted date/time readable for later use.

I found out that the timestamp is Epoch format in miliseconds. Is there a regular way to convert this?

Many thanks in advance

FonsSeesink
  • 21
  • 1
  • 5
  • 2
    possible duplicate of [Converting a UNIX Timestamp to Formatted Date String](http://stackoverflow.com/questions/10040291/converting-a-unix-timestamp-to-formatted-date-string) – John Carter Sep 04 '12 at 03:34

2 Answers2

6

date() function takes the second parameter as the timestamp.

echo date('Y-m-d H:i:s', 1346729259806/1000);
xdazz
  • 158,678
  • 38
  • 247
  • 274
0

You can convert the timestamp to date in mysql by using DATE and FROM_UNIXTIME function. The command given bellow,

FROM_UNIXTIME
SELECT create FROM phpkit ;

The output created:

1216053466

Then:

SELECT DATE( FROM_UNIXTIME( `created` ) ) AS pDate FROM phpkit

Output:

2008-07-14

I found the source from the following link.

jonsca
  • 10,218
  • 26
  • 54
  • 62
vandu
  • 196
  • 1
  • 3
  • 17