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

  • Home
  • SEARCH
  • 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 8742915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:35:05+00:00 2026-06-13T11:35:05+00:00

Iam trying to figure out whetere data was save to the db in the

  • 0

Iam trying to figure out whetere data was save to the db in the las 5 minutes.

SELECT COUNT(id), DATE_FORMAT(`timestamp`, '%Y-%m-%d %H:%i')
FROM `table`
WHERE `timestamp` >= CURRENT_TIMESTAMP - INTERVAL 5 MINUTE

timestamp is a unix timestamp (millisecs from 1970).

doesn’t work, I get nullnum_rows instead of 0 and if I use

if (!isset($resultHistory->num_rows) || !$resultHistory->num_rows)

to do actions, the code does not enter the loop..

I also tried

SELECT COUNT(id), DATE_FORMAT(`timestamp`, '%Y-%m-%d %H:%i')
    FROM `table`
    WHERE DATE_FORMAT(`timestamp`, '%Y-%m-%d %H:%i') >= CURRENT_TIMESTAMP - INTERVAL 5 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-13T11:35:05+00:00Added an answer on June 13, 2026 at 11:35 am

    Current_timestamp returns the current date as a SQL TIMESTAMP, not a UNIX timestamp, so you’d have to convert using the unix_timestamp function:

    SELECT COUNT(id), from_unixtime(`timestamp` / 1000, '%Y-%m-%d %H:%i')
    FROM `table`
    WHERE `timestamp` >= unix_timestamp(CURRENT_TIMESTAMP - INTERVAL 5 MINUTE) * 1000
    

    EDIT:

    As your timestamp column contains unix time, you’re also going to have to use from_unixtime to format the date.

    EDIT2:

    In MySQL UNIX time is the number of seconds since epoch (1/1/70), so if your timestamp column contains the number of milliseconds, you’ll have to divide by 1000 as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to figure out how to create a temporary table that is
I am trying to figure out how to remove a class from a parent
I am trying to figure out how to select with JS everything before Picture_1.png
I'm trying to figure out a basic permission set for an IAM user/key to
Iam using Rails 3.0 and Devise. I am trying to figure out the best
I am trying to figure out how to properly parse some values returned from
i am trying to figure out a way to select all the records in
I am trying to figure out the best way to model a spreadsheet (from
I am trying to figure out following problem. I have a simple rich:select <rich:select
Hi guys iam trying to figure out how i can get an image to

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.