(After sending AJAX / $http POST request from AngularJS to PHP) I am trying to save unix timestamp (as INT
) in my database, but it doesn't work.
It comes from JavaScript in this form: (new Date()).valueOf()
, producing a value in my object: time_stamp : 1513079761979
. When it arrives in my PHP I can echo it (as JSON, for debugging) and see it as ... : 1513079761979
.
So far the value has not been altered. However, when I INSERT
it into my database along with some other values, which work fine, including integers, it saves it as 2147483647
, which is obviously is no longer the same value. There are now 10 digits so I thought the length was too short, but nope.
To fix it, I tried all sorts of methods: casting (int)
in PHP, changing type of attribute to int(32)
(bigger length) in my database. Nothing works.
The only solution I see is to save my integer as string (VARCHAR
or length 1024~), which does work, but I want to know why it fails to accept INT
as is, because I have other variables that I'm saving as integers, so I want to guarantee that those work as expected too.