Dates in PHP and MySQL

Posted under » PHP » MySQL on 18 October 2012

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. You can convert it to a newformat like so.

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

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'));

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