Page 1 of 1

check if unix timestamp is on specific date?

Posted: Fri Jan 18, 2008 11:21 pm
by potato
Hi everybody,

long time no see! I see that devnetwork has got a new look, very nice, clean... +10

Can somebody help me with this problem?
This is the case:

i have a mysql table with members. This table has a field called regidate that contains the unix timestamp of the registration date. Till here, no problem.
Now i want to make a query where i want to call all the members that registered on for example '7 january 08'.
I found a way that works (code beneath), but i feel that this is not the beautifull way to script this case.

Here is how i did it: :crazy: :D

Code: Select all

[color=#FF0000]$query = "SELECT * FROM members WHERE regidate > " . strtotime('7 January 2008')." AND regidate < " . strtotime('8 January 2008')."";[/color]
 
You know a better way to handle this? Please help me...

Many thanx in advance!

grtz,
tom

Re: check if unix timestamp is on specific date?

Posted: Fri Jan 18, 2008 11:58 pm
by potato
Sorry, i just saw that there's a database category. :oops:

Re: check if unix timestamp is on specific date?

Posted: Sat Jan 19, 2008 9:03 am
by VladSun
[sql] SELECT DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP()), '%Y-%m-%d');[/sql]

Re: check if unix timestamp is on specific date?

Posted: Sat Jan 19, 2008 5:16 pm
by John Cartwright
potato wrote:Sorry, i just saw that there's a database category. :oops:
No problem.

Moved to Databases.