Last 5.3 release ever available: PHP 5.3.29 - 5.3 now EOL

DateInterval::createFromDateString

(PHP 5 >= 5.3.0)

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

Description

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.

Parameters

time

Date with relative parts.

Return Values

Returns new DateInterval instance if success.

add a note add a note

User Contributed Notes 2 notes

up
1
Anonymous
4 years ago
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.
up
-18
msleman at boot dot dot dot com
3 years ago
Sample usage:

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