Greenguy's Board


Go Back   Greenguy's Board > Programming & Scripting
Register FAQ Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 2006-12-01, 11:49 AM   #1
Xallow
Hello, is this President Clinton? Good! I figured if anyone knew where to get some tang it would be you
 
Join Date: May 2006
Location: Denmark
Posts: 447
Send a message via ICQ to Xallow
Question Operating with php date

Hi guys and gals

I am trying to do the following:

extract a date from my database, it is MySql and stored as a Date, ie. 2006-11-29

compare this date to todays date using date("Ymd") and find out if the date from the datbase is more or less than 7 days ago, I just cant get it to work!

I won't copy my code here, since it is so messed up that nobody would understand it anyway! a working example would be Highly appreciated and almost worth giving a blowjob for.... almost
__________________
Porn Safe Submit Free Sites
Porn Party Porn Submit Free Sites
Xallow is offline   Reply With Quote
Old 2006-12-01, 12:12 PM   #2
cd34
a.k.a. Sparky
 
cd34's Avatar
 
Join Date: Sep 2004
Location: West Palm Beach, FL, USA
Posts: 2,396
select if('2006-11-01'>date_sub(curdate(),interval 7 day),'within the last week','more than a week old');

something like that will work.

substitute your field name in the place where I put the date
__________________
SnapReplay.com a different way to share photos - iPhone & Android
cd34 is offline   Reply With Quote
Old 2006-12-01, 01:20 PM   #3
oast
With $10,000, we'd be millionaires! We could buy all kinds of useful things like ... love!
 
oast's Avatar
 
Join Date: May 2004
Location: UK
Posts: 316
I use this basic code to do something similar to what you are looking for.

PHP Code:
<?php
$OneWeekAgo 
date('Y-m-d'mktime(000date("m"), date("d")-7date("Y")));
$query DatabaseQuery("SELECT * FROM table");
while(
$rows mysql_fetch_array($query)){
    if (
$rows[lastaction] < $OneWeekAgo)
        echo 
$rows[name].' last action was more than one week ago ('.$rows[lastaction].')<br>'."\n";
    else
        echo 
$rows[name].' was active <b>within the last week</b> ('.$rows[lastaction].')<br>'."\n";
}
?>
Change the table and field names to suit your needs.

** DatabaseQuery(); is a self made database access function, so you will have to alter the query to suit your needs, but the rest is straightforward.
__________________
Playboy Webmasters - The name says it all! $35 per signup or 60% revshare.
oast is offline   Reply With Quote
Old 2006-12-02, 08:58 AM   #4
Xallow
Hello, is this President Clinton? Good! I figured if anyone knew where to get some tang it would be you
 
Join Date: May 2006
Location: Denmark
Posts: 447
Send a message via ICQ to Xallow
thanks guys, it works now
__________________
Porn Safe Submit Free Sites
Porn Party Porn Submit Free Sites
Xallow is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:51 AM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc