php/Mysql query with inserting date fails

前端 未结 3 1524
情深已故
情深已故 2021-01-22 07:50

I have been searching for quite a while now and I can\'t figure out why my query isn\'t working for dates.

I want it to be imported to my database as a Date, this is a c

相关标签:
3条回答
  • 2021-01-22 08:22

    MySQL date format has to be YYYY-MM-DD

    Turn it around so it looks like:

    $_SESSION['Datum'] = $DateJaar.'-'.$DateMaand.'-'.$DateDag;
    
    0 讨论(0)
  • 2021-01-22 08:22

    after date is inserted you can format after query $new_format=date('h:i:s d/m/Y',strtotime($date_string));

    0 讨论(0)
  • 2021-01-22 08:47

    The MySQL date format is actually YYYY-MM-DD, so if you want to insert a date (guessing your datum field is Date or Datetime) you have to set up your string in that way.

    If you want to insert your date in a different way you should use this:

    INSERT INTO enrties (datum) VALUES (str_to_date('01/02/2000', '%d/%m/%Y')); 
    

    but this will save always the date in YYYY-MM-DD way, since is the default for mysql.

    0 讨论(0)
提交回复
热议问题