tags:

views:

76

answers:

1

Hi

I'm working on a way to extract given data from a timestamp in a MySQL. I've been advised to try FROM_UNIXTIME() ... but my development is built around pear::db so I'm looking for a replacement. Have you any suggestions

thankx

A: 

Do you mean a PHP-based solution instead of using SQL? Just use the date() function to format your timestamp:

date("Y-m-d H:i:s", $timestamp);

Specific answer (see comments): to get just the month from this, just change the format string to "m" and leave out everything else.

Andrew Vit
no i've been advised to try the following - but it's a mysql function SELECT * FROM database WHERE MONTH(FROM_UNIXTIME(timestamp)) = 1
So it looks like what you're looking for is a replacement for the MONTH() function, not the FROM_UNIXTIME() function... which is what my answer gives you.
Andrew Vit
I'm learning about timestamps. I can find lots of infomation about extracting data from current timestamps but little about querying a database timestamp (e.g. from the timestamp field return all records from jan)
You'll need to be more clear about what you're trying to do then. Are you asking for something that doesn't use database functions like FROM_UNIXTIME()? Are you trying to select records from one January (e.g. 2009), or all Januarys, regardless of year?
Andrew Vit