For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > March 2005 > Re: [PHP-DB] Newbie: phpmyadmin and searching Unix Timestamps









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] Newbie: phpmyadmin and searching Unix Timestamps
Aman Patel

2005-03-22, 8:55 pm

Graham Anderson wrote:
> is there an easy way to search through unixtimestamps ?
>
> like
> Select * from SessionTable Where ConvertToMonthFunction(unixTimeStamp) =
> 'March' ?
>
> be great to use the Variable function within phpmyAdmin
>
> many thanks
> g
>


On Mysql (works on 4.0 atleast), you can use the FROM_UNIXTIME()
function to convert a unix timestamp back to universal date/time format.
From then on you can use any standard mysql date/time functions to
compare the month. So your query becomes something like:

SELECT * FROM SessionTable WHERE MONTH(from_unixtime(1111527115)) = 3;

MONTH() returns a numeric month number from 1-12. See the mysql
documentation on date and time functions here:

http://dev.mysql.com/doc/mysql/en/d...-functions.html

Hope this helps.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com