void date_date_set ( DateTime $object, int $year, int $month, int $day ); void DateTime::setDate ( int $year, int $month, int $day )
这些函数将日期设置为给定的DateTime对象。在此调用之后,对象将设置新的日期。
object - DateTime对象
month - 月份(1~12)
链接:https://www.learnfk.comhttps://www.learnfk.com/php/php-function-date-date-set.html
来源:LearnFk无涯教程网
day - 月份内的天数(1~31)
year - 年份(4位)
成功时返回NULL,失败时返回FALSE。
<?php $dateSrc='2005-04-19 12:50 GMT'; $dateTime=date_create( $dateSrc);; # Now set a new date using date_date_set(); date_date_set( $dateTime, 2000, 12, 12); echo "New Formatted date is ". $dateTime->format("Y-m-d\TH:i:s\Z"); echo "<br />"; # Using second function. $dateTime=new DateTime($dateSrc); $dateTime->setDate( 1999, 10, 12); echo "New Formatted date is ". $dateTime->format("Y-m-d\TH:i:s\Z"); ?>
这将产生以下输出-
New Formatted date is 2000-12-12T12:50:00Z New Formatted date is 1999-10-12T12:50:00Z
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)
Python实战 · 从0到1搭建直播视频平台 -〔Barry〕