PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 4th, 2005, 01:06 AM
Capt Morgan Capt Morgan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 4 Capt Morgan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 2 m 47 sec
Reputation Power: 0
Post How do I get the Difference between Current and past Dates?

Hi All,
I have a field in a Mysql DB of type Date which stores the current date of inserting data.

I want a PHP script that determines the difference between the Current date and the date the
data was posted in the MySQL DB/Table (past date).

The script is to delete all rows in my table which have been stored in the table for more
than a specified number of days (say 14days).

I'm using PHP Ver 4 and MYSQL 4.1

Reply With Quote
  #2  
Old February 4th, 2005, 06:50 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 997 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2Folding Points: 908096 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 14 h 26 m 27 sec
Reputation Power: 5
Send a message via ICQ to Itsacon
Why use PHP for this?

simply use mysql:
Code:
DELETE FROM tableName WHERE DATE_ADD(dateColumn, INTERVAL 14 DAY) < CURRENT_TIMESTAMP;

Reply With Quote
  #3  
Old February 5th, 2005, 01:20 AM
Capt Morgan Capt Morgan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 4 Capt Morgan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 2 m 47 sec
Reputation Power: 0
Thumbs up Thanx Itascon

Quote:
Originally Posted by Itsacon
Why use PHP for this?

simply use mysql:
Code:
DELETE FROM tableName WHERE DATE_ADD(dateColumn, INTERVAL 14 DAY) < CURRENT_TIMESTAMP;


Thanx Itascon, I've been able to deal with my date problem.

Regards,
Capt. Morgan

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > How do I get the Difference between Current and past Dates?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT