void date_isodate_set ( DateTime $object, int $year, int $week [, int $day] ) void DateTime::setISODate ( int $year, int $week [, int $day] )
这些函数将ISO日期设置到传递的对象中,上述两个函数是等效的,并且可以使用任何函数,如下例所示。
object - DateTime对象
year - 年份(4位)
week - 周
day - 月份内的天数(1~31)
成功时返回NULL,失败时返回FALSE。
<?php $dateSrc='2005-04-19 12:50 GMT'; $dateTime=date_create( $dateSrc);; # Now set a new date using date_isodate_set(); date_isodate_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->setISODate( 1999, 10, 12); echo "New Formatted date is ". $dateTime->format("Y-m-d\TH:i:s\Z"); ?>
这将产生以下输出-
New Formatted date is 2000-03-31T12:50:00Z New Formatted date is 1999-03-19T12:50:00Z
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)
Python实战 · 从0到1搭建直播视频平台 -〔Barry〕