SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: post current date
-
Jan 4, 2001, 22:23 #1
- Join Date
- May 2000
- Location
- Rocky Mount, NC
- Posts
- 74
- Mentioned
- 0 Post(s)
- Tagged
- 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
-
Jan 4, 2001, 23:17 #2
- Join Date
- Aug 1999
- Location
- East Lansing, MI USA
- Posts
- 12,937
- Mentioned
- 0 Post(s)
- Tagged
- 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
-
Jan 5, 2001, 01:22 #3
- Join Date
- Jan 2001
- Location
- Your basement
- Posts
- 192
- Mentioned
- 0 Post(s)
- Tagged
- 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 syntaxOvergrow the Government: The Edge Forums
presented by Overgrow Marijuana Magazine
*warning: adult content
Bookmarks