DateInterval::createFromDateString Sets up a DateInterval from the relative parts of the string &reftitle.description; &style.oop; public static DateIntervalfalseDateInterval::createFromDateString stringdatetime &style.procedural; DateIntervalfalsedate_interval_create_from_date_string stringdatetime Uses the date/time parsers as used in the DateTimeImmutable constructor to create a DateInterval from the relative parts of the parsed string. &reftitle.parameters; datetime A date with relative parts. Specifically, the relative formats supported by the parser used for DateTimeImmutable, DateTime, and strtotime will be used to construct the DateInterval. To use an ISO-8601 format string like P7D, you must use the constructor. &reftitle.returnvalues; Returns a new DateInterval instance on success, &return.falseforfailure;. &reftitle.changelog; &Version; &Description; 8.2.0 Only the from_string and date_string properties will be visible when a DateInterval is created with this method. &reftitle.examples; Parsing valid date intervals ]]> Parsing combinations and negative intervals format('%d %h %i'), "\n"; $i = DateInterval::createFromDateString('1 year - 10 days'); echo $i->format('%y %d'), "\n"; ?> ]]> &example.outputs; 449 2 70 1 -10 Parsing special relative date intervals &example.outputs.82; bool(true) ["date_string"]=> string(22) "last day of next month" } object(DateInterval)#2 (2) { ["from_string"]=> bool(true) ["date_string"]=> string(12) "last weekday" } ]]> &example.outputs.8.similar; int(0) ["m"]=> int(1) ["d"]=> int(0) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["f"]=> float(0) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(2) ["invert"]=> int(0) ["days"]=> bool(false) ["special_type"]=> int(0) ["special_amount"]=> int(0) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(0) } object(DateInterval)#2 (16) { ["y"]=> int(0) ["m"]=> int(0) ["d"]=> int(0) ["h"]=> int(0) ["i"]=> int(0) ["s"]=> int(0) ["f"]=> float(0) ["weekday"]=> int(0) ["weekday_behavior"]=> int(0) ["first_last_day_of"]=> int(0) ["invert"]=> int(0) ["days"]=> bool(false) ["special_type"]=> int(1) ["special_amount"]=> int(-1) ["have_weekday_relative"]=> int(0) ["have_special_relative"]=> int(1) } ]]>