CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C Chronos 3.x API

  • Project:
    • Chronos
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 3.x
      • 3.x
      • 2.x
      • 1.x

Namespaces

  • Cake\Chronos

Class ChronosTime

Namespace: Cake\Chronos

Constants

  • string
    DEFAULT_TO_STRING_FORMAT ¶
    'H:i:s'

    Default format to use for __toString method.

  • int
    TICKS_PER_DAY ¶
    self::TICKS_PER_HOUR * 24
  • int
    TICKS_PER_HOUR ¶
    self::TICKS_PER_MINUTE * 60
  • int
    TICKS_PER_MICROSECOND ¶
    1
  • int
    TICKS_PER_MINUTE ¶
    self::TICKS_PER_SECOND * 60
  • int
    TICKS_PER_SECOND ¶
    1000000

Property Summary

  • $ticks protected
    int
  • $toStringFormat protected static
    string

    Format to use for __toString method.

Method Summary

  • __construct() public

    Copies time from onther instance or from time string in the format HH[:.]mm or HH[:.]mm[:.]ss.u.

  • __toString() public

    Format the instance as a string using the set format

  • between() public

    Returns whether time is between time range.

  • endOfDay() public static

    Returns instance set to end of day - either 23:59:59 or 23:59:59.999999 if $microseconds is true

  • equals() public

    Returns whether time is equal to target time.

  • format() public

    Formats string using the same syntax as DateTimeImmutable::format().

  • getHours() public

    Returns clock hours.

  • getMicroseconds() public

    Returns clock microseconds.

  • getMinutes() public

    Returns clock minutes.

  • getSeconds() public

    Return clock seconds.

  • greaterThan() public

    Returns whether time is greater than target time.

  • greaterThanOrEquals() public

    Returns whether time is greater than or equal to target time.

  • lessThan() public

    Returns whether time is less than target time.

  • lessThanOrEquals() public

    Returns whether time is less than or equal to target time.

  • midnight() public static

    Returns instance set to midnight.

  • mod() protected static
  • noon() public static

    Returns instance set to noon.

  • now() public static

    Returns instance set to server time.

  • parse() public static

    Copies time from onther instance or from string in the format HH[:.]mm or HH[:.]mm[:.]ss.u

  • parseString() protected static
  • resetToStringFormat() public static

    Reset the format used to the default when converting to a string

  • setHours() public

    Set clock hours.

  • setMicroseconds() public

    Sets clock microseconds.

  • setMinutes() public

    Set clock minutes.

  • setSeconds() public

    Set clock seconds.

  • setTime() public

    Sets clock time.

  • setToStringFormat() public static

    Set the default format used when converting to a string

  • toDateTimeImmutable() public

    Returns an DateTimeImmutable instance set to this clock time.

  • toNative() public

    Returns an DateTimeImmutable instance set to this clock time.

Method Detail

__construct() ¶ public

__construct(Cake\Chronos\ChronosTime|DateTimeInterface|string|null $time = null, DateTimeZone|string|null $timezone = null)

Copies time from onther instance or from time string in the format HH[:.]mm or HH[:.]mm[:.]ss.u.

Defaults to server time.

Parameters
Cake\Chronos\ChronosTime|DateTimeInterface|string|null $time optional

Time

DateTimeZone|string|null $timezone optional

The timezone to use for now

__toString() ¶ public

__toString(): string

Format the instance as a string using the set format

Returns
string

between() ¶ public

between(Cake\Chronos\ChronosTime $start, Cake\Chronos\ChronosTime $end, bool $equals = true): bool

Returns whether time is between time range.

Parameters
Cake\Chronos\ChronosTime $start

Start of target range

Cake\Chronos\ChronosTime $end

End of target range

bool $equals optional

Whether to include the beginning and end of range

Returns
bool

endOfDay() ¶ public static

endOfDay(bool $microseconds = false): static

Returns instance set to end of day - either 23:59:59 or 23:59:59.999999 if $microseconds is true

Parameters
bool $microseconds optional

Whether to set microseconds or not

Returns
static

equals() ¶ public

equals(Cake\Chronos\ChronosTime $target): bool

Returns whether time is equal to target time.

Parameters
Cake\Chronos\ChronosTime $target

Target time

Returns
bool

format() ¶ public

format(string $format): string

Formats string using the same syntax as DateTimeImmutable::format().

As this uses DateTimeImmutable::format() to format the string, non-time formatters will still be interpreted. Be sure to escape those characters first.

Parameters
string $format

Format string

Returns
string

getHours() ¶ public

getHours(): int

Returns clock hours.

Returns
int

getMicroseconds() ¶ public

getMicroseconds(): int

Returns clock microseconds.

Returns
int

getMinutes() ¶ public

getMinutes(): int

Returns clock minutes.

Returns
int

getSeconds() ¶ public

getSeconds(): int

Return clock seconds.

Returns
int

greaterThan() ¶ public

greaterThan(Cake\Chronos\ChronosTime $target): bool

Returns whether time is greater than target time.

Parameters
Cake\Chronos\ChronosTime $target

Target time

Returns
bool

greaterThanOrEquals() ¶ public

greaterThanOrEquals(Cake\Chronos\ChronosTime $target): bool

Returns whether time is greater than or equal to target time.

Parameters
Cake\Chronos\ChronosTime $target

Target time

Returns
bool

lessThan() ¶ public

lessThan(Cake\Chronos\ChronosTime $target): bool

Returns whether time is less than target time.

Parameters
Cake\Chronos\ChronosTime $target

Target time

Returns
bool

lessThanOrEquals() ¶ public

lessThanOrEquals(Cake\Chronos\ChronosTime $target): bool

Returns whether time is less than or equal to target time.

Parameters
Cake\Chronos\ChronosTime $target

Target time

Returns
bool

midnight() ¶ public static

midnight(): static

Returns instance set to midnight.

Returns
static

mod() ¶ protected static

mod(int $a, int $b): int
Parameters
int $a

Right side

int $b
Returns
int

noon() ¶ public static

noon(): static

Returns instance set to noon.

Returns
static

now() ¶ public static

now(DateTimeZone|string|null $timezone = null): static

Returns instance set to server time.

Parameters
DateTimeZone|string|null $timezone optional

The timezone to use for now

Returns
static

parse() ¶ public static

parse(Cake\Chronos\ChronosTime|DateTimeInterface|string $time = null, DateTimeZone|string|null $timezone = null): static

Copies time from onther instance or from string in the format HH[:.]mm or HH[:.]mm[:.]ss.u

Defaults to server time.

Parameters
Cake\Chronos\ChronosTime|DateTimeInterface|string $time optional

Time

DateTimeZone|string|null $timezone optional

The timezone to use for now

Returns
static

parseString() ¶ protected static

parseString(string $time): int
Parameters
string $time

Time string in the format HH[:.]mm or HH[:.]mm[:.]ss.u

Returns
int

resetToStringFormat() ¶ public static

resetToStringFormat(): void

Reset the format used to the default when converting to a string

Returns
void

setHours() ¶ public

setHours(int $hours): static

Set clock hours.

Parameters
int $hours

Clock hours

Returns
static

setMicroseconds() ¶ public

setMicroseconds(int $microseconds): static

Sets clock microseconds.

Parameters
int $microseconds

Clock microseconds

Returns
static

setMinutes() ¶ public

setMinutes(int $minutes): static

Set clock minutes.

Parameters
int $minutes

Clock minutes

Returns
static

setSeconds() ¶ public

setSeconds(int $seconds): static

Set clock seconds.

Parameters
int $seconds

Clock seconds

Returns
static

setTime() ¶ public

setTime(int $hours = 0, int $minutes = 0, int $seconds = 0, int $microseconds = 0): static

Sets clock time.

Parameters
int $hours optional

Clock hours

int $minutes optional

Clock minutes

int $seconds optional

Clock seconds

int $microseconds optional

Clock microseconds

Returns
static

setToStringFormat() ¶ public static

setToStringFormat(string $format): void

Set the default format used when converting to a string

Parameters
string $format

The format to use in future __toString() calls.

Returns
void

toDateTimeImmutable() ¶ public

toDateTimeImmutable(DateTimeZone|string|null $timezone = null): DateTimeImmutable

Returns an DateTimeImmutable instance set to this clock time.

Parameters
DateTimeZone|string|null $timezone optional

Time zone the DateTimeImmutable instance will be in

Returns
DateTimeImmutable

toNative() ¶ public

toNative(DateTimeZone|string|null $timezone = null): DateTimeImmutable

Returns an DateTimeImmutable instance set to this clock time.

Alias of toDateTimeImmutable().

Parameters
DateTimeZone|string|null $timezone optional

Time zone the DateTimeImmutable instance will be in

Returns
DateTimeImmutable

Property Detail

$ticks ¶ protected

Type
int

$toStringFormat ¶ protected static

Format to use for __toString method.

Type
string
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs