Parsing timestamps - do it in MySQL or in PHP?

Posted by Andrew Heath on Stack Overflow See other posts from Stack Overflow or by Andrew Heath
Published on 2010-04-11T00:01:43Z Indexed on 2010/04/11 0:03 UTC
Read the original article Hit count: 120

Filed under:
|
|
|

Let's say you've got a table with a timestamp column, and you want to parse that column into two arrays - $date and $time.

Do you, personally:

a) query like this DATE(timestamp), TIME(timestamp) , or perhaps even going as far as HOUR(timestamp), MINUTE(timestamp

b) grab the timestamp column and parse it out as needed with a loop in PHP

I feel like (a) is easier... but I know that I don't know anything. And it feels a little naughty to make my query hit the same column 2 or 3 times for output...

Is there a best-practice for this?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about php