...

View Full Version : How to make a search system for date



mwalam
01-18-2008, 03:58 PM
Hello
I am beginner to PHP. I am making a reporting system for the orders placed by customers. I want that, i enter the date like 18/01/08 into the text box and show me the results by date. The main problem is that date is in 10 digit unix format. i can retrive the date by use date function like
$test = date( 'd/m/y', $title);

please tell me the code.
thanks.

Inigoesdr
01-18-2008, 05:55 PM
If you're using a database you should be using a DATE field to begin with, as it will save you a lot of trouble like this.

$dateFromUserInput = '18/01/08';
list($day, $month, $year) = explode('/', $dateFromUserInput);
$start = mktime(0, 0, 0, $month, $day, $year);

// if you use a database
$end = $start + (60 * 60 * 24);
// SELECT * FROM `table` WHERE `timestamp` > $start AND `timestamp` < $end

mwalam
01-18-2008, 07:23 PM
thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum