?
Solved

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

Posted on 2006-07-23
5
Medium Priority
?
1,526 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

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…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
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 …
Suggested Courses

743 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