How do I use Unix timestamps with the Doctrine Timestampable behavior? I found the following code snippet here, but I\'d rather not manually add this everywhere:
One method would be to use doctorine's listeners to create a unix timestamp equivalent when the record is fetched and before it is saved:
class Base extends Doctrine_Record_Listener
{
public function preHydrate(Doctrine_Event $event)
{
$data = $event->data;
$data['unix_created_at'] = strtotime($data['created_at']);
$data['unix_updated_at'] = strtotime($data['updated_at']);
$event->data = $data;
}
}
This could be your base class that you extend in anything that needs created_at and updated_at functionality.
I'm sure with a little bit more tinkering you could loop through $data and convert all datetime fields 'unix_'.$field_name.
Good luck