Oihana PHP Arango

dateDiff.php

Table of Contents

Functions

dateDiff()  : string
Calculate the difference between two dates in given time unit, optionally with decimal places.

Functions

dateDiff()

Calculate the difference between two dates in given time unit, optionally with decimal places.

dateDiff([string|int|null $date1 = null ][, string|int|null $date2 = null ][, string $unit = DateUnit::DAY ][, bool $asFloat = null ][, string|null $timezone1 = null ][, string|null $timezone2 = null ]) : string
Parameters
$date1 : string|int|null = null

numeric timestamp or ISO 8601 date time string

$date2 : string|int|null = null

numeric timestamp or ISO 8601 date time string

$unit : string = DateUnit::DAY

either of the following to specify the time unit to return the difference in (case-insensitive):

  • "y", "year", "years"
  • "m", "month", "months"
  • "w", "week", "weeks"
  • "d", "day", "days"
  • "h", "hour", "hours"
  • "i", "minute", "minutes"
  • "s", "second", "seconds"
  • "f", "millisecond", "milliseconds"
$asFloat : bool = null

if set to true, decimal places will be preserved in the result. The default is false and an integer is returned.

$timezone1 : string|null = null

if set, date1 is assumed to be in the specified timezone. If timezone2 is not set, then both date1 and date2 are assumed to be in the timezone specified by timezone1, e.g. "America/New_York", "Europe/Berlin", or "UTC". Use "America/Los_Angeles" for Pacific time (PST/PDT).

$timezone2 : string|null = null

if set, date2 is assumed to be in the timezone specified by timezone2, and date1 is assumed to be in the timezone specified by timezone1, e.g. "America/New_York", "Europe/Berlin", or "UTC". Use "America/Los_Angeles" for Pacific time (PST/PDT).

Return values
string
On this page

Search results