PHP中的date_date_set()函数
date_date_set()函数将日期设置为给定的DateTime对象。此后,调用对象将设置新的日期。
语法
date_date_set ( object, year, month, day )
参数
对象-DateTime对象
年-日期的年份
月-日期的月份
日期-日期的日期
返回
date_date_set()函数成功返回NULL,失败返回FALSE。
示例
以下是一个例子-
<?php
$dateSrc = '2017-11-25 11:25 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-12T11:25:00Z New Formatted date is 1999-10-12T11:25:00Z
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短