Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Date Problems -- between now and $last_date
Old 05-09-2008, 02:19 AM Date Problems -- between now and $last_date
Junior Talker

Posts: 1
Name: Alea Scovill
Trades: 0
Ok -- pulling current date from date(); and pulling last date from mysql database and converting both to Month (F) format.

Code to find current month:
$current_month = date(F);
echo $current_month;

Code to find last month listed:
$q_maxdate = mysql_query("SELECT MAX(start_date) from courses.courseschedule;");
$q_maxdate_result = mysql_fetch_row($q_maxdate);
$q_maxdate_result = $q_maxdate_result[0];
$date = new DateTime($q_maxdate_result);
$format_late_date = $date->format("F");
echo $format_late_date;

Would like to be able to find the months between those two dates and then post them.

Anyone know how? Can't really +1 to a date????

Thanks
alea_scovill is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-09-2008, 03:39 AM Re: Date Problems -- between now and $last_date
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Not sure about your DB dates functions, but look at them, rather than doing this in PHP.
It's way more easy...
If you are using mysql5, what you want to look upon is the dateAdd():
http://dev.mysql.com/doc/refman/5.0/...nction_adddate
Code:
mysql> SELECT DATE_ADD('1998-01-02', INTERVAL 31 DAY);
        -> '1998-02-02'
Similar functions exists in almost every databases, and are more flexible than parsing the pure date value in PHP.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 05-09-2008, 07:08 AM Re: Date Problems -- between now and $last_date
Average Talker

Posts: 15
Name: Mark
Trades: 0
You can also try this to get dates within the last X days, so if you wanted dates within the last 30 days try

PHP Code:

SELECT 
FROM db_name WHERE TO_DAYSNOW(  'y-m-d'  )  )  - TO_DAYSdate )  >= 30 
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Datingsoftware is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Date Problems -- between now and $last_date
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12324 seconds with 12 queries