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
how do i check if a date is greater than 3 months old
Old 03-20-2012, 09:29 AM how do i check if a date is greater than 3 months old
numbenator's Avatar
Webmaster Talker

Posts: 534
Location: London
Trades: 0
Hi there

I have a datetime field taken from a SQL table

I want to check if the date is older than 3 months from today given that i have set a php variable to = the datetime value

$datetocheck = $row['datetime']

I want to work with $datetocheck

any help would be appreciated.

Thanks

Steve
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
 
Register now for full access!
Old 03-20-2012, 12:00 PM Re: how do i check if a date is greater than 3 months old
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,960
Name: Keith Marshall
Location: Connecticut
Trades: 0
PHP Code:
if (strtotime($datetocheck) > strtotime("+3 months"))
{
    
// Is greater than 3 months from now

__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 03-21-2012, 01:40 PM Re: how do i check if a date is greater than 3 months old
lizciz's Avatar
Super Spam Talker

Posts: 845
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Depending on what your purpose is, it might be easier/better to make the comparison in your SQL query instead, when retreiving the data. As in
Code:
SELECT a,b,c,my_time
FROM table
WHERE my_time < DATE_SUB(now(), INTERVAL 3 MONTH)
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Reply     « Reply to how do i check if a date is greater than 3 months old
 

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.30238 seconds with 11 queries