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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:56:51+00:00 2026-06-10T08:56:51+00:00

I have trouble with date data type. I have a php mysql pdo statement:

  • 0

I have trouble with date data type.
I have a php mysql pdo statement:

$mystmt = $mydb->prepare("
    SELECT  `ad_id` 
        FROM `tbl_actions`
        WHERE 
            (`actiondate` > :nowcookietime  )
");
$mystmt->execute(array(
            ':nowcookietime'=>date("Y-m-d H:i:s", time()-$cookiedurationlock),
           )
);
$testnotinsql = $mystmt->fetch(PDO::FETCH_ASSOC); // EMPTY

The code run return empty. But if i get the sql below from general_log and run in sql tool (HeidiSQL), it will return record.
SQL from general_log:

SELECT  ad_id 
        FROM tbl_actions
        WHERE 
            (actiondate> '2012-08-24 17:53:21' ) 

My PHP timezone is UTC+7
Mysql is SYSTEM (which UTC)
As I understand it’s not timezone problem if insert and query in php using same timezone.

I test the bind parameter with force string

':nowcookietime'=>date("Y-m-d H:i:s", time()-$cookiedurationlock),

but it’s same empty.

BUT: if use quote then it return rows

':nowcookietime'=>"'".date("Y-m-d H:i:s", time()-$cookiedurationlock)."'",

Can you clarify what wrong with this statement as I understand we dont need quote, mysql pdo quote for us.

EDIT 1:

I update the correct sql. With quote in sql is my mistake when take from test. The without quote around :nowcookietime stil empty.

CLOSED
See my answer below.

  • 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-10T08:56:52+00:00Added an answer on June 10, 2026 at 8:56 am

    I find out why.

    1. Basicly there’s script set the $cookiedurationlock too short, so most the time it empty.
    2. When add quote, the comparation will be (actiondate > ‘\’2012-08-25 02:28:22\” ), so it will return rows.
    3. After the query, there is a insert new action row. So when i run trace sql from tools, data was change and it return the new one which added after this sql.

    I think I have to organize my script to simpler ones.
    Thanks all for your help.

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

Sidebar

Related Questions

I have an SSIS exportation package that is used to export data from an
I have data stored in a csv file that looks like this: Date,BLOCK,,Wood,Miscellaneous,,Totals,MO Saturday,4055-RU,4055-AR,4091,1139,1158,,100
I want to extract data from database where field end_ date is less than
I'm working on a project where I have to gather data from GPS devices
I'm having some trouble with MySql right now. I have an query that works
I have trouble with creating an approval form as am still php beginner, the
I have trouble figuring out why a simple division like this one always returns
We have trouble implementing a nice session mechanism in JSP. One of our requirement
I have trouble with strange behavior of for..in cycle in JavaScript. I have the
I have trouble doing this... You may want to get the same result as

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.