当在数据库中输入的日期是YYYY-MM-DD格式时,如何制作此格式?
问题描述:
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____. "
How can I make this format when the date entered in database is in YYYY-MM-DD format?
Thank you!
我有一个表格,管理员输入日期。 之后它会创建一个这样的字母。 p>
“你必须在_____,______ ___日出现在我面前。” em> p >
当在数据库中输入的日期是YYYY-MM-DD格式时,如何制作此格式? p>
谢谢! p>
答
$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