---
title: "PHP date()函数写入mysql的格式"
author: "yeahfeng"
date: "2012-11-08T11:41:40Z"
tags: []
categories: ["编程语言"]
slug: "php-date-mysql"
draft: false
lastmod: "2012-11-08T11:41:40Z"
id: 1720198
url: "https://yeahfeng.iteye.com/blog/1720198"
---

&lt;?php   
echo date("Y-m-d");   
//显示格式为：XXXX-XX-XX   
//必须使用上面这种格式存入mysql的date字段中   
echo date("Y-m-d H:i:s");   
//显示格式为：XXXX-XX-XX XX:XX:XX   
//必须使用上面这种格式存入mysql的datetime字段中   
?&gt;