简体   繁体   English

当数据库中输入的日期为YYYY-MM-DD格式时,如何设置此格式?

[英]How can I make this format when the date entered in database is in YYYY-MM-DD format?

I have a form where the admin enters a date. 我有一个表单,其中管理员输入日期。 After that it will create a letter like this. 之后,它将创建一个像这样的字母。

"You are hereby required to appear before me on the ___ day of _____, 20____. " “特此要求您在____年20月__日的____日出现在我面前。”

How can I make this format when the date entered in database is in YYYY-MM-DD format? 当数据库中输入的日期为YYYY-MM-DD格式时,如何设置此格式?

Thank you! 谢谢!

$date = "2011-07-26"; // put your date here <br>
$date = strtotime($date); <br>
$day =  date('d', $date); //it will get only the day <br>
$month = date('M', $date); //I'm not sure what you want try 'm' <br>
$year= date('Y', $date); //or 'y'

I hope it helps you 希望对您有帮助

Try this 尝试这个

$date="28-01-2016";//Put Date Here
//convert to database type
$db_date_format=date('Y-m-d',strtotime($date));

it helps you 它可以帮助你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM