PHP Class Jenssegers\Date\Date

Inheritance: extends Carbon\Carbon
Datei anzeigen Open project: jenssegers/date Class Usage Examples

Protected Properties

Property Type Description
$fallbackLocale string The fallback locale when a locale is not available.
$lastErrors array The errors that can occur.
$translator Symfony\Component\Translation\Translator The Translator implementation.

Public Methods

Method Description
__construct ( string $time = null, string | DateTimeZon\DateTimeZone $timezone = null ) : Date Returns new DateTime object.
add ( string | DateInterva\DateInterval $interval ) : Date Adds an amount of days, months, years, hours, minutes and seconds to a Date object.
ago ( Date $since = null, boolean $absolute = false ) : string Alias for diffForHumans.
createFromFormat ( string $format, string $time, DateTimeZon\DateTimeZone | string $timezone = null ) : static Create a Carbon instance from a specific format.
diffForHumans ( Carbon\Carbon $since = null, boolean $absolute = false, $short = false ) : string Get the difference in a human readable format.
format ( string $format ) : string Returns date formatted according to given or predefined format.
getFallbackLocale ( ) : string Get the fallback locale.
getLocale ( ) : string Get the current translator locale.
getTranslator ( ) : Translator Return the Translator implementation.
make ( string $time = null, string | DateTimeZon\DateTimeZone $timezone = null ) : Date Create and return new Date instance.
parse ( string $time = null, string | DateTimeZon\DateTimeZone $timezone = null ) : Date Create a carbon instance from a string.
setFallbackLocale ( string $locale ) : void Set the fallback locale.
setLocale ( string $locale ) : void Set the current locale.
setTranslator ( Symfony\Component\Translation\TranslatorInterface $translator ) Set the Translator implementation.
sub ( string | DateInterva\DateInterval $interval ) : Date Subtracts an amount of days, months, years, hours, minutes and seconds from a DateTime object.
timespan ( Date $time = null, string | DateTimeZon\DateTimeZone $timezone = null ) : integer Gets the timespan between this date and another date.
translateTimeString ( string $time ) : string Translate a locale based time string to its english equivalent.
until ( Date $since = null ) : string Alias for diffForHumans.

Method Details

__construct() public method

Returns new DateTime object.
public __construct ( string $time = null, string | DateTimeZon\DateTimeZone $timezone = null ) : Date
$time string
$timezone string | DateTimeZon\DateTimeZone
return Date

add() public method

Adds an amount of days, months, years, hours, minutes and seconds to a Date object.
public add ( string | DateInterva\DateInterval $interval ) : Date
$interval string | DateInterva\DateInterval
return Date

ago() public method

Alias for diffForHumans.
public ago ( Date $since = null, boolean $absolute = false ) : string
$since Date
$absolute boolean Removes time difference modifiers ago, after, etc
return string

createFromFormat() public static method

Create a Carbon instance from a specific format.
public static createFromFormat ( string $format, string $time, DateTimeZon\DateTimeZone | string $timezone = null ) : static
$format string
$time string
$timezone DateTimeZon\DateTimeZone | string
return static

diffForHumans() public method

Get the difference in a human readable format.
public diffForHumans ( Carbon\Carbon $since = null, boolean $absolute = false, $short = false ) : string
$since Carbon\Carbon
$absolute boolean Removes time difference modifiers ago, after, etc
return string

format() public method

Returns date formatted according to given or predefined format.
public format ( string $format ) : string
$format string
return string

getFallbackLocale() public static method

Get the fallback locale.
public static getFallbackLocale ( ) : string
return string

getLocale() public static method

Get the current translator locale.
public static getLocale ( ) : string
return string

getTranslator() public static method

Return the Translator implementation.
public static getTranslator ( ) : Translator
return Symfony\Component\Translation\Translator

make() public static method

Create and return new Date instance.
public static make ( string $time = null, string | DateTimeZon\DateTimeZone $timezone = null ) : Date
$time string
$timezone string | DateTimeZon\DateTimeZone
return Date

parse() public static method

Create a carbon instance from a string.
public static parse ( string $time = null, string | DateTimeZon\DateTimeZone $timezone = null ) : Date
$time string
$timezone string | DateTimeZon\DateTimeZone
return Date

setFallbackLocale() public static method

Set the fallback locale.
public static setFallbackLocale ( string $locale ) : void
$locale string
return void

setLocale() public static method

Set the current locale.
public static setLocale ( string $locale ) : void
$locale string
return void

setTranslator() public static method

Set the Translator implementation.
public static setTranslator ( Symfony\Component\Translation\TranslatorInterface $translator )
$translator Symfony\Component\Translation\TranslatorInterface

sub() public method

Subtracts an amount of days, months, years, hours, minutes and seconds from a DateTime object.
public sub ( string | DateInterva\DateInterval $interval ) : Date
$interval string | DateInterva\DateInterval
return Date

timespan() public method

Gets the timespan between this date and another date.
public timespan ( Date $time = null, string | DateTimeZon\DateTimeZone $timezone = null ) : integer
$time Date
$timezone string | DateTimeZon\DateTimeZone
return integer

translateTimeString() public static method

Translate a locale based time string to its english equivalent.
public static translateTimeString ( string $time ) : string
$time string
return string

until() public method

Alias for diffForHumans.
public until ( Date $since = null ) : string
$since Date
return string

Property Details

$fallbackLocale protected_oe static_oe property

The fallback locale when a locale is not available.
protected static string $fallbackLocale
return string

$lastErrors protected_oe static_oe property

The errors that can occur.
protected static array $lastErrors
return array

$translator protected_oe static_oe property

The Translator implementation.
protected static Translator,Symfony\Component\Translation $translator
return Symfony\Component\Translation\Translator