0

首先,我在上一页输入 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。我该怎么办??请帮忙。

4

2 回答 2

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。请参见此处

于 2012-10-17T08:53:11.607 回答
0

$myDate = date ("y-m-d", $time );
应该像这样使用大写“Y”:
$myDate = date ("Y-m-d", $time );

php docs对数据字符串格式有很好的解释:这里

于 2012-10-17T08:53:18.063 回答