check if unix timestamp is on specific date?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
potato
Forum Contributor
Posts: 192
Joined: Tue Mar 16, 2004 8:30 am
Location: my lovely trailer, next to the big tree

check if unix timestamp is on specific date?

Post 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
User avatar
potato
Forum Contributor
Posts: 192
Joined: Tue Mar 16, 2004 8:30 am
Location: my lovely trailer, next to the big tree

Re: check if unix timestamp is on specific date?

Post by potato »

Sorry, i just saw that there's a database category. :oops:
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: check if unix timestamp is on specific date?

Post by VladSun »

[sql] SELECT DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP()), '%Y-%m-%d');[/sql]
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: check if unix timestamp is on specific date?

Post by John Cartwright »

potato wrote:Sorry, i just saw that there's a database category. :oops:
No problem.

Moved to Databases.
Post Reply