[Solar-talk] Date & Time types

Paul M Jones pmjones at solarphp.com
Fri Jan 18 09:22:28 CST 2008


I know there's a lot of emails backlogged, but this one is an easy  
reply.

On Jan 18, 2008, at 08:49 , Kilbride, James P. wrote:
> Why do I see this:
>
>         'date'              => 'date',
>         'datetime'          => 'timestamp',
>         'timestamp'         => 'int',
>         'time'              => 'time',
>
> In the MYSQL Adapter for solar? Why is the mysql timestamp type  
> being converted to an int? Is it because mysql's timestamp is number  
> of seconds?
>
The idea is to stick with ISO 8601 definitions for "date", "time", and  
"timestamp".  In ISO 8601, "timestamp" is "yyyy-mm-dd hh:ii:ss".

For MySQL, the "timestamp" type is the Unix epoch (32-bit number of  
seconds since Jan 1 1970 iirc), but the MySQL "datetime" type maps to  
the ISO 8601 definition of "timestamp".  So if you want the Unix  
epoch, it's an INT number of seconds, and if you want yyyy-mm-dd  
hh:ii:ss, it's a DATETIME.  (For PostgreSQL it's much the same thing.)

Hope that helps explain what's going on there.


-- pmj


More information about the Solar-talk mailing list