How the system recognize 10am and 10pm?
Main Topics
Browse All TopicsI have a db that store a datetime using php code:
date("Y-m-d h:i:s", time()+(3600*8))
The date stored is 2005-12-12 05:49:07 . Time now is 05:49 pm.
If I want to looks for record that are between 10am - 5pm today, what php code should I use?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
for the php part, either you use the H instead the h for the 24 hour notation, OR you put the AM/PM modifier using a or A
http://php.net/date
Try this one
<?
$first = date("Y-m-d H:i:s", mktime(10,0,0));
$second = date("Y-m-d H:i:s", mktime(17,0,0));
$result = array();
$query = mysql_query("SELECT * FROM table WHERE date BETWEEN $first AND $second;") or die(mysql_error());
while ($row = mysql_fetch_assoc($query))
$result[] = $row;
}
print_r($result);
?>
Its searching for records between 10 and 17 o'clock..
If you have any control over this program, and how it is getting into the database, rembmer that you do not have to read this out of a database, only a computer does. So keep your inserts into the database in a computer readable format. By that I mean, it would be better to put it in this format YYYYMMDDHHMMSS.
Then you could put an index on that column, and then say SELECT * FROM $tablename WHERE date > '20050505000000';
By indexing that column, and putting in that format, you can really speed up searching.
Business Accounts
Answer for Membership
by: angelIIIPosted on 2005-12-12 at 01:57:17ID: 15465139
please look here to learn how to compare date and times in MySQL: efman/5.0/ en/date-an d-time- fun ctions.htm l
http://dev.mysql.com/doc/r