MySQL/PHP Date

This is a discussion on "MySQL/PHP Date" within the PHP Forum section. This forum, and the thread "MySQL/PHP Date are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jan 31st, 2008, 16:32
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
MySQL/PHP Date

Hey all. I have a post stored in a table, with a field called date. On the website, I want to display the following using PHP/MySQL: This puzzle ends on: (date of puzzle + 1 week).

So, it takes the date the puzzle was added to the table, and adds 1 week to it, and displays that date.
My current code is:
PHP: Select all

$get_latpuz mysql_query("SELECT contentid, contenttitle, category, homepage, date_format(date, '%b %D, %Y') AS date FROM content WHERE category='Puzzles' ORDER BY contentid DESC LIMIT 0 ,1");
while (
$lat_puz mysql_fetch_array($get_latpuz)) {
$postid $lat_puz['contentid'];
$posttitle $lat_puz['contenttitle'];
$postdate $lat_puz['date'];
echo 
'<li><a href="single.php?contentid=' $postid '">' $posttitle '</a></li>';

Then I want to add:
PHP: Select all

echo 'Puzzle ends on: (Date + 1 Week)'
Hope I made sense.

Jack
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote

  #2 (permalink)  
Old Jan 31st, 2008, 17:00
Junior Member
Join Date: Mar 2007
Location: indiana
Age: 25
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to kidreapertronV
Re: MySQL/PHP Date

I wish I could give you specifics about how to insert this into your particular code, but I'm pretty sure you can specify the puzzle ends on date by using this code...

PHP: Select all

DATE_ADD(CURDATE(),INTERVAL 1 WEEK
Check out the MySQL info on DATE_ADD() for more info.

Good luck!
Reply With Quote
  #3 (permalink)  
Old Jan 31st, 2008, 17:44
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: MySQL/PHP Date

No luck I'm afraid. Cannot figure out how to intergrate it in. Any ideas?
Appreciate the help so far
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
Reply

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to compaire Stored Dates with System Date (PHP-MYSQL) jeffry PHP Forum 3 Feb 22nd, 2007 02:15
Convert date to MySQl format AdRock PHP Forum 4 Jan 15th, 2007 09:41
Changing date format in date picker AdRock JavaScript Forum 1 Aug 1st, 2006 17:16
Date in Asp Gup Classic ASP 1 Jun 5th, 2006 09:05
asp date Monie Classic ASP 1 Sep 21st, 2004 04:38


All times are GMT. The time now is 07:23.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43