Link to home
Start Free TrialLog in
Avatar of rhinez0rz
rhinez0rz

asked on

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

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
Avatar of Khanh Doan
Khanh Doan
Flag of United States of America image

<?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.
ASKER CERTIFIED SOLUTION
Avatar of TeRReF
TeRReF
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of arun80_inin
arun80_inin

do you want to add 10 days to the current date
Avatar of rhinez0rz

ASKER

Thanks TeRReF, I think my question was a little vague, but you answered it perfectly. Fantastic!
You're welcome!