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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:47:42+00:00 2026-06-06T11:47:42+00:00

In our project we use Zend Framework Model generator, which produces something like this

  • 0

In our project we use Zend Framework Model generator, which produces something like this to set the properties that are stored in DB (MySQL) as DATETIME fields:

public function setObjectDatetime($data) {
  if (! $data instanceof Zend_Date) { ... some conversion code ... }
  $this->objectDatetime = $data->toString(Zend_Date::ISO_8601);
}

So the ISO::8601 formatted string (‘2012-06-15T18:33:00+03:00’ for example) is what actually is stored as a property.

The problem arises when we try to save this model, and pass this string to MySQL (version 5.5.16): it raise the warning, but still inserts/updates the corresponding row with a correct result. It’s easy to check that the issue is caused by MySQL, and not some drivers’ behaviour: just issue such query as…

UPDATE table_name SET datetime_field = '2012-06-15T18:33:00+03:00' WHERE id = 1;

… and the result will be 1 row affected, 1 warning, with

1264 | Out of range value for column 'dt' at row 1

warning (shown by SHOW WARNINGS).

To my amuzement, phpMyAdmin doesn’t show any warnings at all; and all the server-side code processed this query as a solid one. )

So the question is: should we really reformat what we store in our Model into another string format (‘YY-MM-dd HH:mm:ss’, for example?) Or is it just some weird behavior of MySQL that will be fixed sooner or later?

  • 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-06T11:47:44+00:00Added an answer on June 6, 2026 at 11:47 am

    It looks like the short answer to this question is “No, it’s not safe” – this conclusion follows a series of experiments with MySQL shell. Still would appreciate a more “theoretical” answer, though…

    Apparently MySQL engine is (by default) pretty liberal in what it accepts as a Datetime literal even with sql_mode set to STRICT_ALL_TABLES : not only various separators are accepted, they may differ as well:

    INSERT INTO t(dt) VALUES('2012-01,03.04:05@06'); -- Query OK, 1 row affected

    Besides, if the string is too short, it will be padded with zeroes… but there might be surprises:

    INSERT INTO t(dt) VALUES('2012011'); -- 2020-12-01 01:00:00 is what's inserted

    The sad thing is that the string too long (when the last parsable digit is followed by something other than whitespace) will be considered an invalid value in strict mode:

    mysql> INSERT INTO t(dt) VALUES('2012-06-27T05:25Z');
    ERROR 1292 (22007): Incorrect datetime value: '2012-06-27T05:25Z' for column 'dt' at row 1
    mysql> INSERT INTO t(dt) VALUES('2012-06-27T05:25');
    Query OK, 1 row affected (0.10 sec)
    

    In the traditional mode parsing is even more relaxed – but not more precise; besides, the strings that are considered incorrect in the strict mode will give sort of ‘silent warnings’, though operations will succeed:

    mysql> INSERT INTO t(dt) VALUES('2012-06-27T05:25Z');
    Query OK, 1 row affected, 1 warning (0.10 sec)
    
    mysql> SHOW WARNINGS;
    +---------+------+---------------------------------------------+
    | Warning | 1264 | Out of range value for column 'dt' at row 1 |
    +---------+------+---------------------------------------------+
    
    mysql> SELECT dt FROM t;
    +---------------------+
    | dt                  |
    +---------------------+
    | 2012-06-27 05:25:00 |
    +---------------------+
    

    The bottom line is that we had to rewrite some DAL-related code so that dates (and datetimes) are always sent to the DB in “normalized” form. I wonder why it’s we who have to do it, and not Zend_Db developers. But that’s another story, I suppose. )

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

Sidebar

Related Questions

I'm interested in replacing an aging control we use in our project that is
i want to use stripes in our new project. This will take care of
For our rewrite of the open-source iMedia framework project (in use currently by dozens
There are few open source projects/APIs/libraries that we use in our project ( Spring,
If I use ADO.NET Entity Framework in our project and we depend on a
In one library that is in heavy use in our project there is a
I'm trying to implement dependency injection in our Zend Framework project. In previous APS.NET
Our project makes use of gilead to pass model objects to the client side
In our project we use test data that is stored inside .sql files that
In our project we use MVC3 with a domain model and NHibernate as DAL.

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.