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 7741601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:04:07+00:00 2026-06-01T09:04:07+00:00

i have a timestamp problem. i would like to check a timestamp if that

  • 0

i have a timestamp problem. i would like to check a timestamp if that is in the past or future. if it is in the past, a query should happens.

up to this point i got a mysql-timestamp that will be fetched by

$row = $query->fetch_object();
$timestamp = $row->time

that contains:

2012-04-04 12:06:38

for further settings i use two more variables which will be:

$added = $timestamp + 1209600;  //what adds 14days (1209600 seconds) to my db-timestamp
$check = $added < time();  //what checks if the 14days have passed or not

okay now if i test all of these with var_dump it will return for each:

string(19) "2012-04-04 12:06:38" at var_dump($timestamp)
int(1211612) at var_dump($added)
bool(true) at var_dump($check)

so my problem is, that the following query will be executed all the time, even in case of when the 14days should have been passed. i know that because i changed the timestamp to earlier date in january. here is my query:

if ($check === true){
    $update = $db->query("UPDATE table SET xy='1' WHERE x='$x'");
    }

something seems to be wrong and i have no clue what that might be.

  • 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-01T09:04:08+00:00Added an answer on June 1, 2026 at 9:04 am

    I agree with barsju. The result from MySQL is a string of the DateTime entry and not actually a timestamp. Another option that would keep it within PHP is strtotime($string); that will translate the string into its timestamp. All that matters is that you get a timestamp before your check.

    I would do it on this line of your example:

    $timestamp = strtotime($row->time);
    

    I believe there are also a couple other ways to get MySQL to return the timestamp instead as well.

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

Sidebar

Related Questions

I have a unix timestamp that I would like to convert using mysql if
I have a php class that tells time like this (Time.class.php): <?PHP class Time
I have a little problem with fluentNhibernate and MySQL. I would like to map
I have a timestamp with timezone information in string format and I would like
I have a Unix timestamp that I need to get the individual year, month,
I have a number of domains pointed to the same webserver and would like
I would like to have optimized version of my WinForms C# based application for
I've written quite a few jQuery plugins in the past and this problem has
I have an NSArray of Object that has an interesting property that I would
Problem: I have a database of sensor readings with a timestamp for the time

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.