mysql date formatting with php

前端 未结 6 1751
庸人自扰
庸人自扰 2021-01-29 02:56

I have a date (\"mm/dd/yyyy\") and I want to convert it to a MySQL DATE data type (like yyyy-mm-dd)

How do I do it with PHP?

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-29 03:28

    $date = '12/25/2011';
    $parts = explode('/', $date);
    $sql_date = $parts[2] . '-' . $parts[0] . '-' . $parts[1];
    

提交回复
热议问题