How to update only the year value of the table using PHP and MySQL

advertisements

I need one help. I have some date value in my table in mm/dd/yyyy format but some record has wrong year like 1969/70 and i need to change change those year part only using PHP and MySQL. I am explaining my table below.

db_restaurant_basic:

 id                date                                         name 

 1           01/01/1970 05:30:00 AM                              Raj

 2          12/16/1970 04:30:00 AM                              Rahul

 3          01/01/2017 05:30:00 AM                              Roy

Here my date format is like mm/dd/yyyy this. I am explaining my query below.

$sqlcollect=mysqli_query($connect,"select * from db_restaurant_basic");
while ($row=mysqli_fetch_array($sqlcollect)) {
  $edate=$row['date'];
}

Here I need to change only the year and update it again in the table. If month is in between 06-12 the year should be 2016 and for month 01 the year should be 2017. The expected output for 01/01/1970 05:30:00 AM should be 01/01/2017 05:30:00 AM and for 12/16/1970 04:30:00 AM should be 12/16/2016 04:30:00 AM. Please help me.


try this.. it will change years with + and -, to current date

$new_date = date('Y-m-d', strtotime('+1 years', strtotime($edate)));

and update new_date using query