Get the difference between two dates in PHP

Description

The following code shows how to get the difference between two dates.

Example


/*  w  w  w  .  j  ava2s  .  com*/
<?php
    $date1=date_create("2014-03-15");
    $date2=date_create("2014-12-12");
    $diff=date_diff($date1,$date2);
?>




















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone