How to save field TimeStamp data type?

If I have in MySQL table field timestamp type, how to save data?

I get string like ‘1378283588’ (it’s timestamp) and I would like to store it like timestamp in DB.

If I dod $this->save($data['Model"][‘my_time’] = ‘1378283588’ - I get “0000-00-00 00:00:00” . I see it in phpMyAdmin.

I think in MySQL the column type needs to be INT(11) if you want unix style timestamp.

hakim> Yes, but it INT. MySQL has timestamp type.

Dude, MySQL timstamp is not unix time, it’s the data type is used for values that contain both date and time parts. TIMESTAMP has a range of ‘1970-01-01 00:00:01’ UTC to ‘2038-01-19 03:14:07’ UTC.

If you want to save unix time, then the column needs to be INT.

hakim> It’s clear.

But if I would like to save dada in a field with timestamp type, How to prepare it?
in MySQL I can use the function FROM_UNIXTIME .

Thank you.

It would have to be string iso date format “YYYY-DD-MM HH:MM:SS” … Do you need this for “created” and “modified” columns? Cake can do this for you with timestamp behaviour:

So when a record is created or modified, cake will update these for you.

However the column in MySQL needs to be “datetime” not “timestamp” for this to work.

I know this feature and use it. I get data from another service.