Erik, > PHP's mktime() function uses a timestamp that is the number of seconds > since the Unix epoch. MySQL uses the YYYYMMDDhhmmss format for its > TIMESTAMP column type. > > I'm not complaining that they're not the same, but curious as to which I > should use for storing timestamps -- does it matter? PHP has a lot of
MySQL timestamps should be stored in a timestamp column - unless your application runs contrary to the automatic updating rule. (Manual 6.2.2.2 The DATETIME, DATE, and TIMESTAMP Types) > nice formatting conventions with date(), so I am leaning towards using > mktime() to store PHP-style timestamps into a MySQL TIMESTAMP column. > But MySQL does have the ability to format dates, and its TIMESTAMP > column type bumps up if I don't manually insert a value. Don't forget that you will need a UNIX call to translate the UNIX Epoch timestamp from PHP integer into MySQL Timestamp format. Would it not be easier to use FROM_UNIXTIME() and plug straight into a MySQL DATETIME string column - with no danger of auto-update? The choice comes down to how you are generating the time data prior to its storage in the db, and how you plan to use it afterwards. If you are going to be doing lots of temporal processing in PHP, then UNIX timestamp is the way to go. If it is purely a 'label' then stick with that format - even storing a string in MySQL that it doesn't realise is a date! Both PHP and MySQL have a wide range of time/date functions to support such activities. Regards, =dn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php