Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> MySQL
Author Message
plankton
New Member
New Member



Joined: Jan 22, 2007
Posts: 20

PostPosted: Mon Mar 05, 2007 7:03 pm Reply with quote

Hi all,

I want to query a table for all records with a given date... the problem I'm having is that the tables have the date stored as a timestamp -> 1173135145...

I know that -
$today = date("l jS F Y"); - will give me todays date
echo "Todays Date is: $today<br>"; // display e.g: Saturday 10th March 2001

and -
$today2 = time(); - will give me todays date as a timestamp (and as I understand it the time as well but that isn't needed)
echo "Todays Date as timestamp: $today2<br>"; // display e.g: 1173135145

and to make the timestamp more readable -
$today2_formatted = date('l jS F Y', $today2);
echo "Todays Date as formatted timestamp: $today2_formatted<br>"; // display e.g: Saturday 10th March 2001

Now thats all well and good for display purposes, BUT How do I query the table to select all records that have 'Todays' date??

SELECT * FROM table_name WHERE date=$today

doesn't seem to work and I can't work out how to get 'Todays date' as a timestamp without the 'time'.

Any help is much appreciated
 
View user's profile Send private message
Gremmie
Former Moderator in Good Standing



Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA

PostPosted: Mon Mar 05, 2007 7:13 pm Reply with quote

See the FROM_UNIXTIME() and UNIX_TIMESTAMP() functions in the MySQL documentation.

_________________
Only registered users can see links on this board! Get registered or login! - An Event Calendar for PHP-Nuke
Only registered users can see links on this board! Get registered or login! - A Google Maps Nuke Module 
View user's profile Send private message
plankton







PostPosted: Thu Mar 08, 2007 2:41 pm Reply with quote

Ok Gremmie, I'll take a look

Thanks!
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> MySQL

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©