小白教程
所有教程
关于
Search
172.69.6.111
172.69.6.111
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Func date interval format”的源代码
本页内容
上一节:
Func_date_get_last_errors
下一节:
Func_date_isodate_set
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:date_interval_format()}}[[Category:PHP Date 参考手册|11]] = PHP date_interval_format() 函数 = [[:Category:PHP Date 参考手册]] 计算两个日期间的间隔,然后格式化时间间隔: <sample title="" desc="" lang="php" hererun="1"> <?php $date1=date_create("2013-01-01"); $date2=date_create("2013-02-10"); $diff=date_diff($date1,$date2); // %a 输出两个日期间隔的总天数 echo $diff->format("日期间隔的总天数为: %a 天。"); ?> </sample> == 定义和用法 == date_interval_format() 函数是 DateInterval::format() 的别名。 DateInterval::format() 函数用于格式化时间间隔。 == 语法 == <pre> DateInterval::format(format); </pre> {| class="table table-striped table-hover" !width="50%"| 参数 !width="50%"| 描述 |- | format | 必需。规定格式。format 参数字符串可以使用下列的字符: * % - Literal % * Y - 年,至少 2 个数字,带前导零(例如 03) * y - 年(例如 3) * M - 月,带前导零(例如 06) * m - 月(例如 6) * D - 日,带前导零(例如 09) * d - 日(例如 9) * a - 由 date_diff() 得出的两个日期间隔的总天数 * H - 小时,带前导零(例如 08、23) * h - 小时(例如 8、23) * I - 分,带前导零(例如 08、23) * i - 分(例如 8、23) * S - 秒,带前导零(例如 08、23) * s - 秒(例如 8、23) * R - 当负数时为符号 "-",当正数时为符号 "+" * r - 当负数时为符号 "-",当正数时为空 '''注意:'''每个格式字符串必须带一个 % 符作为前缀! |} == 技术细节 == {| class="table table-striped table-hover" | 返回值: | 返回格式化的时间间隔。 |- | PHP 版本: | 5.3+ |} [[:Category:PHP Date 参考手册]]
返回至“
Func date interval format
”。
上一节:
Func_date_get_last_errors
下一节:
Func_date_isodate_set