SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: time codes...

  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 1999
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, I want to compare some values over a period of time?
    Say, a program has to compare two values, each of which has its own date.

    How should I do that via php/mysql?

    Thank you.

    Ian Chiu
    Editor in Chief
    http://www.usbworkshop.com/

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ian where are these dates stored? in a MySQL date field? What type of comparison's do you need to make on them? If it is just simple php like is 2001-01-25 < 2001-01-26 then you can do just that

    $date1 = "2001-01-25";
    $date2 = "2001-01-26";

    if ($date1 < $date2) {
    //true
    }
    else {
    //false
    }

    Give us some more detail on what you are trying to do, and we can better assist you.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 1999
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I got that one to work...

    Anyway, could you tell me how to retrieve items for the past seven days? My dates are stored in this format, 20010127000000.

    Ian Chiu
    Editor in Chief
    http://www.usbworkshop.com/

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use MySQL DATE TIME FUNTIONS to create a date 7 days prior to otday and see if any records are newer than it.

    $result = mysql_query("SELECT * from table name WHERE
    DATE_SUB(CURDATE(), INTERVAL 7 DAY) < datefield");
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

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