Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to make a search system for date

    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.

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    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.
    PHP Code:
    $dateFromUserInput '18/01/08';
    list(
    $day$month$year) = explode('/'$dateFromUserInput);
    $start mktime(000$month$day$year);

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

  • #3
    New to the CF scene
    Join Date
    Jan 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •