Jump to content

Working with dates


Kryptix

Recommended Posts

Hi chaps,

 

I have a table with a column called 'time' which is PHP's TIME() or MySQL's UNIX_TIMESTAMP(), I need to allow a user to search between two certain times. They should be able to specify the start time and the end time and it will show all results before then.

 

The 'time' column is obviously a INT (10), what query would I use? Something like this, or is there something more specific?

 

SELECT * FROM `table` WHERE `time` > '" . $start . "' AND `time` < '" . $end . "'

 

Also, does anyone know of a script or whatever where you can select a date from a pop-up window or something?

 

What's the function to turn 01/12/2009 into a TIME()?

Link to comment
https://forums.phpfreaks.com/topic/191909-working-with-dates/
Share on other sites

strtotime()

$date = "01/12/2009";
$time = strtotime($date);

 

thats how you can convert dates of most any format into a unix timestamp.

 

 

as far as the query, yeah it looks fine.

 

 

I'm not sure what you mean by

Also, does anyone know of a script or whatever where you can select a date from a pop-up window or something?

 

care to clarify?

Link to comment
https://forums.phpfreaks.com/topic/191909-working-with-dates/#findComment-1011522
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.