Overview

Namespaces

  • Apptus
    • ESales
      • Connector
        • Report
        • Time
    • Util
      • Cache
  • PHP

Classes

  • CalendarDate
  • Duration
  • IsoDate
  • IsoDateTime
  • Month
  • OrdinalDate
  • Time
  • TimeInterval
  • TimePoint
  • Unit
  • WeekDate
  • Weekday
  • Overview
  • Namespace
  • Class
  • Tree

Class Unit

Constants and static methods for time units.

Namespace: Apptus\ESales\Connector\Time
Located at Connector/Time/Unit.php
Methods summary
public static string
# symbol( string $unit )

Parameters

$unit
unit.

Returns

string
A one-character representation of the unit.

Throws

InvalidArgumentException
if the unit is not one of the constants from this class.
public static string
# forSymbol( string $symbol )

Parameters

$symbol
one-character representation of a unit.

Returns

string
The unit associated with the symbol.

Throws

InvalidArgumentException
if no unit is associated with the symbol.
public static string
# displayName( string $unit, DateTime $dt )

Formats a DateTime depending on the unit.

Formats a DateTime depending on the unit.

Parameters

$unit
$dt

Returns

string

Throws

InvalidArgumentException
if the unit is not one of the constants from this class.
public static DateTime
# add( DateTime $dt, integer $amount, string $unit )

Moves a DateTime {@code $amount} units in time.

Moves a DateTime {@code $amount} units in time.

Use a positive amount to move forward and a negative amount to move backwards.

Parameters

$dt
$amount
number of units to move.
$unit
unit. Must be one of the constants in Unit.

Returns

DateTime
The DateTime for chaining.
public static DateTime
# floor( DateTime $dt, string $unit, string $firstDayOfWeek = 'Mon' )

Returns a new DateTime moved back in time to the closest whole unit.

Returns a new DateTime moved back in time to the closest whole unit.

Parameters

$dt
DateTime to floor.
$unit
unit. Must be one of the constants in Unit.
$firstDayOfWeek
english three letter abbreviation for the first day of the week, e.g. 'Mon' or 'Sun'. Only needed when unit is WEEK.

Returns

DateTime
A new DateTime.

Throws

InvalidArgumentException
public static DateTime
# ceil( DateTime $dt, string $unit, string $firstDayOfWeek = 'Mon' )

Returns a new DateTime moved forward in time to the closest whole unit.

Returns a new DateTime moved forward in time to the closest whole unit.

Will not change the DateTime if the time is already ceiled.

Parameters

$dt
DateTime to ceil.
$unit
unit. Must be one of the constants in Unit.
$firstDayOfWeek
english three letter abbreviation for the first day of the week, e.g. 'Mon' or 'Sun'. Only needed when unit is WEEK.

Returns

DateTime
A new DateTime.
public static DateTime
# round( DateTime $dt, string $unit, string $firstDayOfWeek = 'Mon' )

Returns a new DateTime moved to the closest whole unit.

Returns a new DateTime moved to the closest whole unit.

Will not change the DateTime if the time is already at the start of a unit.

Parameters

$dt
DateTime to ceil.
$unit
unit. Must be one of the constants in Unit.
$firstDayOfWeek
english three letter abbreviation for the first day of the week, e.g. 'Mon' or 'Sun'. Only needed when unit is WEEK.

Returns

DateTime
A new DateTime.
Constants summary
string SECOND
# 'SECOND'
string MINUTE
# 'MINUTE'
string HOUR
# 'HOUR'
string DAY
# 'DAY'
string WEEK
# 'WEEK'
string MONTH
# 'MONTH'
string YEAR
# 'YEAR'
Apptus ESales Connector PHP API documentation generated by ApiGen