Solved

using php return data from Mysql where datetime column is 30 mins or older

Posted on 2013-06-14
6
454 Views
Last Modified: 2013-06-14
Hi

I'm using PHP to look into my mySQL data and return some for sale items. I want non paying members to NOT see new additions so there is a 30 minute delay for them.

How can I create that in the PHP code please?

an example datetime entry in my datebase is : 2013-06-04 12:34:56

so, a user visiting at 2013-06-04 12:44:56 should not see it yet a visitor coming after 30 mins of the datetime 2013-06-04 14:34:56 can see it.

Neil
0
Comment
Question by:NeilT
  • 3
  • 2
6 Comments
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
Comment Utility
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 250 total points
Comment Utility
A sample query might go something like this...
$then = date('c', strtotime('now - 30 minutes'));
$sql = "SELECT ... WHERE addition_time <= '$then' ORDER BY...";
0
 
LVL 51

Accepted Solution

by:
Julian Hansen earned 250 total points
Comment Utility
This can be done in MySQL like so
SELECT * FROM yourtable WHERE entrytime < NOW() - INTERVAL 30 MINUTE;

Open in new window

0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 3

Author Closing Comment

by:NeilT
Comment Utility
Many thanks these 2 tips worked a treat
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Thanks for the points - good question! ~Ray

PS: Take note of the possibilities of time differences between the client and the server, and also the possibility that the MySQL server may have time settings independent of the PHP server.
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
and also the possibility that the MySQL server may have time settings independent of the PHP server

This is relevant only if the date/time information is originating from the PHP Server.

If the records are being updated with a NOW() or CURRENT_TIMESTAMP action then MySQL server time would be the definitive source and the MySQL approach would be the correct way to search for records.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How can I do this in Pyhton? 12 66
Modify PHP Code on the Fly? 8 38
Phone Dialer 5 35
Instering to MySQL table 5 15
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now