i have a created field in datetime and a modified field in timestamp.
this is my code
date_default_timezone_set('America/Los_Angeles');
if ($this->isNewRecord)
$this->created = date("Y-m-d h:i:s");
$this->modified = date("Y-m-d h:i:s");
when i create a new record i see datetime and timestamp with same time in Los Angeles time but i expect timestamp field to be in UTC.
i mean if datetime field is something like ‘.. 08:00:00′ timestamp should be ’16:00:00’ because US time is (UTC -08:00) and DOC says
TIMESTAMP values are converted from the current time zone to UTC for
storage
TIMESTAMPfieds are in fact converted to UTC for storage. That means, it’s stored this way, but when selected it will be converted to connection’s timezone. You can do an experiment: change your timezone (see below) to something else, and do the select for that timestamp.Here’s MySQL docs about handling timezones
added: some console output for illustration