user-44651
user-44651

Reputation: 4124

Unix timestamps giving distant future year

I have several time-stamps returned from a JSON call. I need to save these a MySQL db.

I have tried to echo them here.

echo date("Y-m-d G:i:s", 1460132362766) . "<br>";
echo date("Y-m-d G:i:s", 1460133219681) . "<br>";
echo date("Y-m-d G:i:s", 1460133397608) . "<br>";

but the results are

48239-10-03 3:59:26

48239-10-13 2:01:21

48239-10-15 3:26:48

I thought the proper time-stamp format for data type of timestamp in MySQL Y-m-d G:i:s

What am I doing wrong?

Upvotes: 1

Views: 331

Answers (1)

u_mulder
u_mulder

Reputation: 54831

What you have now is timestamp in milliseconds which is 1000 times bigger. Just simply do:

echo date("Y-m-d G:i:s", 1460133397608/1000) . "<br>";

Upvotes: 1

Related Questions