首先我在上一页输入e6 = 24-09-2011作为输入类型=“文本”:
$a6 = $_POST["e6"] ;
$time = strtotime( $a6 );
$myDate = date ("y-m-d", $time );
echo $myDate ;
$n = strtotime(date("Y-m-d", strtotime($myDate)) . " +$a7 month");
$q = date("Y-m-d", $n);
echo $q ;
out put: 11-09-24 2013-09-24
我想打印2011而不是11。我该怎么办?请帮助。
答案 0 :(得分:3)
$a6 = $_POST["e6"] ;
$time = strtotime( $a6 );
$myDate = date ("Y-m-d", $time );
echo $myDate ;
$n = strtotime(date("Y-m-d", strtotime($myDate)) . " +$a7 month");
$q = date("Y-m-d", $n);
echo $q ;
您需要将所有小写字母y更改为大写字母Y See here。
答案 1 :(得分:0)
$myDate = date ("y-m-d", $time );
应该像资本'Y'一样:
$myDate = date ("Y-m-d", $time );
Php docs对数据字符串格式有一个非常好的解释:Here