📜  dateinterval php代码示例

📅  最后修改于: 2022-03-11 14:54:49.053000             🧑  作者: Mango

代码示例1
diff($d1);
print_r( $diff ) ;
?>

// Note: it now DOES return microsecond differences, in the key 'f':

 0
    [m] => 0
    [d] => 0
    [h] => 0
    [i] => 0
    [s] => 0
    [f] => 0.251066
    [weekday] => 0
    [weekday_behavior] => 0
    [first_last_day_of] => 0
    [invert] => 1
    [days] => 0
    [special_type] => 0
    [special_amount] => 0
    [have_weekday_relative] => 0
    [have_special_relative] => 0
)
?>

sub($one_year);
?>

Please note that the hour field can be negative, especially in the context of switching to/from Daylight savings.

Example:
diff($date_1)->format("%a:%h:%i:%s");
  // returns 21:-1:30:20
?>