The date 00-00-0000 will not be determined. Only 0000-00-00 and all.

  • @LLIAKAJI, so this is the natural format in which the date is stored in the database. - Deonis
  • and how to make the day, month, year stored in php $ date = date ("dmY"); and there is nothing there. CLEAR - LLIAKAJI
  • one
    @ LIAKAJI, sorry, why bother torturing yourself with the question of what format is it stored in? It is considered to be good practice to store the date in TIMESTAMP , and process it as you need it already during data output. - Deonis
  • Fatal error: Call to undefined function TIMESTAMP () in C: \ web \ xampp \ htdocs \ www \ user \ post.php on line 28 here’s how it responds - LLIAKAJI
  • @Deonis, this is where it is considered good form to store the date in TIMESTAMP. And if it is necessary that the date was earlier than 1970? - Nord001

1 answer 1

It seems something like that.

To insert into the database:

If the field is a Datetime type:

$dates = date('Ymd H:i:s', strtotime('2010-10-12 15:09:00') ); $query = "INSERT INTO timeTable(time) VALUES ('$dates')"; 

If the field is of type Date:

 $dates = date('Ym-d', strtotime('2010-10-12 15:09:00') ); $query = "INSERT INTO timeTable(time) VALUES ('$dates')"; 

For output to PHP:

 echo date('dm-Y', strtotime($row['time']) ); 

Read more about: strtotime

  • and what instead to write 2010-10-12 15:09:00? - LLIAKAJI