DateInterval
在线手册:中文 英文
PHP手册

DateInterval::createFromDateString

(PHP 5 >= 5.3.0)

DateInterval::createFromDateStringSets up a DateInterval from the relative parts of the string

说明

public static DateInterval DateInterval::createFromDateString ( string $time )

Uses the normal date parsers and sets up a DateInterval from the relative parts of the parsed string.

参数

time

Date with relative parts.

返回值

Returns new DateInterval instance if success.


DateInterval
在线手册:中文 英文
PHP手册
PHP手册 - N: Sets up a DateInterval from the relative parts of the string

用户评论:

msleman at boot dot dot dot com (29-Oct-2010 04:39)

Sample usage:

<?php
$interval
= DateInterval::createFromDateString('1 month');
?>

Anonymous (28-Sep-2009 08:02)

DateInterval::createFromDateString ( string $time )

When the manual says "Uses the normal date parsers" it means that this function cannot take $time = ISO8601 strings like "P7D".  If you want to use those, you must use the constructor.