MySQL has three date types for use in columns. These are DATETIME, DATE, and TIMESTAMP.

Supposing you have a string in this format 2019-02-25 13:43:15 or DATETIME in var $hari. You can convert it to a newformat like so.

$time = strtotime($hari);
$newformat = date('Y-m-d',$time);
echo $newformat;
// 2019-02-25

The strtotime() function converts to unix timestamp.

Or if already in string format $lahir.

$newformat = date('j F Y', strtotime($lahir));
echo $newformat;
// 25 February 2019

If you want to add an extra day.

$tomorrow = date('Y-m-d H:i:s', strtotime($newformat. ' +1 day'));

In MySQL, sometimes you may encounter this Incorrect datetime value error when you use sql query. Instead of strtotime in PHP, you use STR_TO_DATE. The code looks like this.

UPDATE `resume` SET `ctime` = '0000-00-00 00:00:00' # error
UPDATE `resume` SET `ctime` = STR_TO_DATE("0000-00-00 00:00:00", "%m-%d-%Y %H:%i:%s")

In some cases your MySQL is running on STRICT_MODE so it won't work. You still have to give a real date. So give it a fake one.

UPDATE `resume` SET `ctime` = '2023-01-01' #will work even in datetime

See also DateTime class and weeknumber using the date() function

web security linux ubuntu python django git Raspberry apache mysql php drupal cake javascript css AWS data