HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

date_interval_create_from_date_string

Description

The date_interval_create_from_date_string of Date / Time for PHP sets up a DateInterval from the relative parts of the string.

Syntax

date_interval_create_from_date_string(
    string $datetime
): DateInterval|false

Parameters

datetime

A date with relative parts. Specifically, the relative formats supported by the parser used for strtotime() and DateTime will be used to construct the DateInterval.

Return

Returns a new DateInterval instance on success, or false on failure.

Examples

1 · datetime

<?

$datetime = "1 year 1 month 1 week 1 day 1 hour 1 minute 1 second";

$return = date_interval_create_from_date_string($datetime);

print_r($return);
DateInterval Object
(
    [from_string] => 1
    [date_string] => 1 year 1 month 1 week 1 day 1 hour 1 minute 1 second
)