Solved

Incorrect datetime value: '20060723173061' for column 'upgrade_date' at row 1

Posted on 2006-07-23
5
1,367 Views
Last Modified: 2012-06-27
I get the following error whenever I UPDATE a column with now()+10:

Incorrect datetime value: '20060723173061' for column 'upgrade_date' at row 1

I believe the reason is that the last two digits '61' cannot exist in date format, this would be the same as saying 61 seconds, when there can only be 60 seconds in a minute. How do I create an update function that will round to the next minute in this instance so I don't get this error?

Many thanks
0
Comment
Question by:rhinez0rz
5 Comments
 
LVL 10

Expert Comment

by:Khanh Doan
ID: 17165516
<?php
$date = '20060723173061';
$seconds = substr($date, 12, 2);
$minutes = substr($date, 10, 2);
$rest = substr($date, 0, 10);

if ($seconds >= '60')
{
      $seconds = $seconds - 60;
      if ($seconds < 10)
      {
            $seconds = '0' . $seconds;
      }

      $minutes++;
}
$newdate = $rest . $minutes . $seconds;
echo $newdate;
?>

Goodluck.
Bonmat86.
0
 
LVL 29

Accepted Solution

by:
TeRReF earned 500 total points
ID: 17165892
You are mixing up two types. datetime and timestamp. You must convert the timestamp (time()+10) to datetime first before you make the insert.

$newdate = date("YmdHis", time()+10);
0
 
LVL 2

Expert Comment

by:arun80_inin
ID: 17168165
do you want to add 10 days to the current date
0
 

Author Comment

by:rhinez0rz
ID: 17170679
Thanks TeRReF, I think my question was a little vague, but you answered it perfectly. Fantastic!
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17170685
You're welcome!
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question