Results 1 to 3 of 3

Thread: [RESOLVED] Comparing Time

  1. #1
    Join Date
    May 2009

    resolved [RESOLVED] Comparing Time

    I am trying to make a list that will only show events that have happened. The event is put in by month day and year. Here is my code:

    PHP Code:
    $todaysdate strtotime('now');
    $sql "SELECT * FROM cle";
    $result=mysql_query($sql) or die("Couldn't execute query: ".mysql_error());
    while (
    $rows=mysql_fetch_array($result)) {
    $month $rows['month'];
    $day $rows['day'];
    $year $rows['year'];
    $cutoffdate strtotime($month/$day/$year);

    $cutoffdate <= $todaysdate){
    } else {

    Last edited by beylah; 01-20-2014 at 09:49 AM.

  2. #2
    Join Date
    May 2009


    $cutoffdate = "$month/$day/$year";

    if(strtotime($cutoffdate) < strtotime('now')) {

  3. #3
    Join Date
    Mar 2007
    Even simpler would be store dates as a time reference so you have both a time frame and a date, this being similar to the JavaScript new Date().getTime() which is a reference in milliseconds.

    Any future comparison will be based on a simple X < Y test.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Recent Articles