Solved

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

Posted on 2006-07-23
5
1,287 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
Comment Utility
<?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
Comment Utility
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
Comment Utility
do you want to add 10 days to the current date
0
 

Author Comment

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

Expert Comment

by:TeRReF
Comment Utility
You're welcome!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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 …
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
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 …

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now