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

Posts: 1
Name: Alea Scovill
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
 
When You Register, These Ads Go Away!
Old 05-09-2008, 02:39 AM Re: Date Problems -- between now and $last_date
tripy's Avatar
Fetchez la vache!

Posts: 2,054
Name: Thierry
Location: In the void
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.
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Old 05-09-2008, 06:08 AM Re: Date Problems -- between now and $last_date
Average Talker

Posts: 15
Name: Mark
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 
Datingsoftware is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Date Problems -- between now and $last_date
 

Thread Tools

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

vB 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.14527 seconds with 12 queries