Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8053623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:54:45+00:00 2026-06-05T07:54:45+00:00

I have a mongodb that will be storing visitor data. I need to delete

  • 0

I have a mongodb that will be storing visitor data. I need to delete the data after ten minutes of not being active and will run a command through a cron. How would I do this?

Currently the collection is setup like so:

{ "_id" : ObjectId("4fd33e0b0feeda3b2406f6be"), "name" : "Dugley Reanimator", "updated" : "Some form of timestmap" }

How should I go about storing a timestamp that I search the collection with I.E for my MySql version:

$sql = mysql_query('DELETE FROM `visitors` WHERE NOW() > DATE_ADD(`last_seen`, INTERVAL 10 MINUTE)');
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:54:46+00:00Added an answer on June 5, 2026 at 7:54 am

    Your driver will use a MongoDate time (this may map to a more native representation in PHP).
    You can then query using something like the following mongo statement:

    db.myCollection.find({updated : { $lte : new ISODate("2012-06-09T16:22:50Z") } })
    

    A rough translation for PHP would be:

    $search = array(
      'updated' => array(
        '$lte' => new MongoDate($tenMinutesAgo))
    );
    $collection->find($search)
    

    Or (Caveat: not tested):

    $tenMinutesAgo = new DateTime();
    $tenMinutesAgo->modify('-10 minutes');
    
    $search = array('updated' => array('$lte' => $tenMinutesAgo));
    $collection->find($search)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that will use flask and mongodb; I will probably host
I have a collection of articles in MongoDB that has the following structure: {
I have a Rails application that works with mongodb. I want to deploy it
I am writing a Maintenance Script for MongoDB that will compact collections from a
I have blog with only one author. Author encapsulates many different fields that will
I have a collection of data that looks as follows: id name c1 c2
I need a regular expression that will match on all terms in a set
I have a mongoDB collection with an array field that represents the lists the
If I have data in my users collection that looks like: { name: '...',
So I'm building an app using PHP and MongoDB which will have a fair

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.