SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2000
    Rocky Mount, NC
    0 Post(s)
    0 Thread(s)
    I want to try something in PHP where it will only post information with the current date on it and change day to day.

    Does anyone know how to do this?
    Stuart Briscar Consulting - Free Website Consulting

  2. #2
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    East Lansing, MI USA
    0 Post(s)
    0 Thread(s)
    The info would be stored in a DB.

    I don't know the exact functions but your SQL would like this this:

    Select *
    From Tablename
    Where Date_Column = datefunction

    Every language is going to have a method to display the current date, you may need to format it using a date formatting function for it to work in your SQL query but thats how you'd do it.

    I've made a few newspaper sites and though its in CF the logic of the programming is the same. Each article has a life span marked by its start_date and end_date. In the query it just loads articles where currentdate <= end_date and >= start_date. Each article has a life span of a week usually.

    Here you'd only need 1 column in your DB for date if you only wanted the duration of whatever it is you're doing to be 1 day, if you wanted it to be a week you could do it the method I outlined above with 2 columns in your DB.

    So just look up the PHP date functions, or someone will post em, and thats all there is to it.

    <Edited by aspen on 01-04-2001 at 11:19 PM>
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  3. #3
    SitePoint Zealot Overgrow's Avatar
    Join Date
    Jan 2001
    Your basement
    0 Post(s)
    0 Thread(s)
    86400 seconds in a day so to select something a day old you would compare it's stored time() dateline with:

    time() - 84000;

    Or to compare back a few days

    time() - ($numofdays * 84000);

    $query = "SELECT * FROM table WHERE dateline > '".(time()-84000)."'";

    off the top so excuse any syntax
    Overgrow the Government: The Edge Forums
    presented by Overgrow Marijuana Magazine

    *warning: adult content


Posting Permissions

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