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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:49:06+00:00 2026-06-01T16:49:06+00:00

I observed this strange problem. Inserting with now() is fine, but when adding a

  • 0

I observed this strange problem. Inserting with now() is fine, but when adding a number to now() it sometimes inserts 0. It seems random.

This is the query

mysql_query("INSERT INTO action_data (user_id, value, create_time, site_id) VALUES (807809, 20, now()+$i, 409666)");

the table: ENGINE=InnoDB AUTO_INCREMENT=164865 DEFAULT CHARSET=latin1

mysql_version

+-------------------------+------------------------------------------+
| Variable_name           | Value                                    |
+-------------------------+------------------------------------------+
| innodb_version          | 1.0.13-11.6                              |
| protocol_version        | 10                                       |
| version                 | 5.1.52-rel11.6-log                       |
| version_comment         | Percona Server (GPL), 11.6, Revision 140 |
| version_compile_machine | x86_64                                   |
| version_compile_os      | unknown-linux-gnu                        |
+-------------------------+------------------------------------------+

I ran it 100 times in a loop and about first 1/3ish of them are inserted with time 0 and rest of them are fine. Anybody have an idea why it’s happening?

  • 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-01T16:49:07+00:00Added an answer on June 1, 2026 at 4:49 pm

    Guessing here…but it seems in a numeric context (like, say, if you add a number to the return value), NOW() returns a timestampish-looking number (not a count of seconds!). Like, today it might return 20120409161530.000000. Now…depending on the value of $i, it seems this could easily make for an invalid value. I mean, what if it’s 666666? You’d end up with 20120409828196.000000, which makes no sense as a timestamp…and i’m pretty sure that MySQL just turns invalid values to 0.

    You may want to consider something like NOW() + INTERVAL $i SECOND, and redefine $i to be the number of seconds (or minutes, days, even years if you like…just change SECOND to whatever you decide on). Your resulting times are less likely to turn out all messed up.

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

Sidebar

Related Questions

This is a common question, but the explanations found so far and observed behaviour
I'm having a strange problem with the HTML5 manifest file under Chrome 5.0.375.99 but
I observed this strange behaviour of center method of str objects in python 2.7
I observed a strange problem in a piece of code where an adhoc SQL
I experience a strange problem. Sometimes our Java app will not start and will
For example, I often use this: [self performSelector:@selector(doSomethingAfterDelay:) withObject:someObject afterDelay:someDelay]; Now, lets say I
I often find this strange CDATA tag in XML files: <![CDATA[some stuff]]> I have
I've observed a strange thing about EditText widgets. If you adjust the layout_height downwards,
This is not technically a programming question but it does specifically relate to a
I observed a strange behavior == operator in java. I am trying to print

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.