public function getCreatedAt()
return date('Y-m-d\TH:i:sP', $this->createdAt);
public function setCreatedAt($value)
$this->createdAt = date('YOUR DB FORMAT "U" FOR UNIXTIMESTAMP', strtotime($value));
As long as the property is protected the model will use the public accessors to interact with it, so this will work like a charm:
You set your timezone and anything time zone related stuff in main bootstrap file, and both your web app and CLI app can inhreit that settings. For instance, I keep such settings in config.ini so they can be easily changed by non-developers.
You don't have to save int (timestamp) in a database as such, at least for MySQL/MariaDB since timestamp column will have that by default in a background for you so you can query it with timestamp or with regular human readable date and time.
RFC-3339 provided here is PHP way, so Phalcon can only use that. You can put it whenever you want, in Models too, why not? The important part is that you can get ouput of the preferred date format in one line.
Fetching datetime from a client is a bad idea IMHO, it's always better to use time() i.e. timestamp on the server side and to present human readable format to the client.
For a database structure, here's what I use:
`request_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
`response_timestamp` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP