CakePHP
  • 文档
    • 书籍
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 徽标和商标
  • 业务解决方案
  • 纪念品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 参与
    • 问题 (Github)
    • 烘焙坊
    • 特色资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 时事通讯
    • 领英
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • 帮助和支持
    • 论坛
    • Stack Overflow
    • IRC
    • Slack
    • 付费支持
CakePHP

C Chronos 3.x API

  • 项目
    • Chronos
      • CakePHP
      • Chronos
      • Elastic Search
      • 队列
  • 版本
    • 3.x
      • 3.x
      • 2.x
      • 1.x

命名空间

  • Cake\Chronos

ChronosTime 类

命名空间: Cake\Chronos

常量

  • string
    DEFAULT_TO_STRING_FORMAT ¶
    'H:i:s'

    用于 __toString 方法的默认格式。

  • 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

属性摘要

  • $ticks protected
    int
  • $toStringFormat protected static
    string

    用于 __toString 方法的格式。

方法摘要

  • __construct() public

    从另一个实例或从格式为 HH[:.]mm 或 HH[:.]mm[:.]ss.u 的时间字符串中复制时间。

  • __toString() public

    使用设置的格式将实例格式化为字符串。

  • between() public

    返回时间是否在时间范围内。

  • endOfDay() public static

    返回设置为一天结束的实例 - 如果 $microseconds 为真,则为 23:59:59 或 23:59:59.999999。

  • equals() public

    返回时间是否等于目标时间。

  • format() public

    使用与 DateTimeImmutable::format() 相同的语法格式化字符串。

  • getHours() public

    返回时钟小时。

  • getMicroseconds() public

    返回时钟微秒。

  • getMinutes() public

    返回时钟分钟。

  • getSeconds() public

    返回时钟秒。

  • greaterThan() public

    返回时间是否大于目标时间。

  • greaterThanOrEquals() public

    返回时间是否大于或等于目标时间。

  • lessThan() public

    返回时间是否小于目标时间。

  • lessThanOrEquals() public

    返回时间是否小于或等于目标时间。

  • midnight() public static

    返回设置为午夜的实例。

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

    返回设置为正午的实例。

  • now() public static

    返回设置为服务器时间的实例。

  • parse() public static

    从另一个实例或从格式为 HH[:.]mm 或 HH[:.]mm[:.]ss.u 的字符串中复制时间。

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

    将用于转换为字符串的格式重置为默认值。

  • setHours() public

    设置时钟小时。

  • setMicroseconds() public

    设置时钟微秒。

  • setMinutes() public

    设置时钟分钟。

  • setSeconds() public

    设置时钟秒。

  • setTime() public

    设置时钟时间。

  • setToStringFormat() public static

    设置转换为字符串时使用的默认格式。

  • toDateTimeImmutable() public

    返回设置为此时钟时间的 DateTimeImmutable 实例。

  • toNative() public

    返回设置为此时钟时间的 DateTimeImmutable 实例。

方法详细

__construct() ¶ public

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

从另一个实例或从格式为 HH[:.]mm 或 HH[:.]mm[:.]ss.u 的时间字符串中复制时间。

默认设置为服务器时间。

参数
Cake\Chronos\ChronosTimeDateTimeInterface|string|null $time optional

时间

DateTimeZone|string|null $timezone optional

用于现在的时区

__toString() ¶ public

__toString(): string

使用设置的格式将实例格式化为字符串。

返回
string

between() ¶ public

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

返回时间是否在时间范围内。

参数
Cake\Chronos\ChronosTime $start

目标范围的开始

Cake\Chronos\ChronosTime $end

目标范围的结束

bool $equals optional

是否包含范围的开始和结束

返回
bool

endOfDay() ¶ public static

endOfDay(bool $microseconds = false): static

返回设置为一天结束的实例 - 如果 $microseconds 为真,则为 23:59:59 或 23:59:59.999999。

参数
bool $microseconds optional

是否设置微秒

返回
static

equals() ¶ public

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

返回时间是否等于目标时间。

参数
Cake\Chronos\ChronosTime $target

目标时间

返回
bool

format() ¶ public

format(string $format): string

使用与 DateTimeImmutable::format() 相同的语法格式化字符串。

由于它使用 DateTimeImmutable::format() 来格式化字符串,因此非时间格式化程序仍将被解释。请确保首先转义这些字符。

参数
string $format

格式字符串

返回
string

getHours() ¶ public

getHours(): int

返回时钟小时。

返回
int

getMicroseconds() ¶ public

getMicroseconds(): int

返回时钟微秒。

返回
int

getMinutes() ¶ public

getMinutes(): int

返回时钟分钟。

返回
int

getSeconds() ¶ public

getSeconds(): int

返回时钟秒。

返回
int

greaterThan() ¶ public

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

返回时间是否大于目标时间。

参数
Cake\Chronos\ChronosTime $target

目标时间

返回
bool

greaterThanOrEquals() ¶ public

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

返回时间是否大于或等于目标时间。

参数
Cake\Chronos\ChronosTime $target

目标时间

返回
bool

lessThan() ¶ public

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

返回时间是否小于目标时间。

参数
Cake\Chronos\ChronosTime $target

目标时间

返回
bool

lessThanOrEquals() ¶ public

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

返回时间是否小于或等于目标时间。

参数
Cake\Chronos\ChronosTime $target

目标时间

返回
bool

midnight() ¶ public static

midnight(): static

返回设置为午夜的实例。

返回
static

mod() ¶ protected static

mod(int $a, int $b): int
参数
int $a

右侧

int $b
返回
int

noon() ¶ public static

noon(): static

返回设置为正午的实例。

返回
static

now() ¶ public static

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

返回设置为服务器时间的实例。

参数
DateTimeZone|string|null $timezone optional

用于现在的时区

返回
static

parse() ¶ public static

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

从另一个实例或从格式为 HH[:.]mm 或 HH[:.]mm[:.]ss.u 的字符串中复制时间。

默认设置为服务器时间。

参数
Cake\Chronos\ChronosTimeDateTimeInterface|string $time 可选

时间

DateTimeZone|string|null $timezone optional

用于现在的时区

返回
static

parseString() ¶ protected static

parseString(string $time): int
参数
string $time

格式为 HH[:.]mm 或 HH[:.]mm[:.]ss.u 的时间字符串

返回
int

resetToStringFormat() ¶ public static

resetToStringFormat(): void

将用于转换为字符串的格式重置为默认值。

返回
void

setHours() ¶ public

setHours(int $hours): static

设置时钟小时。

参数
int $hours

时钟小时

返回
static

setMicroseconds() ¶ public

setMicroseconds(int $microseconds): static

设置时钟微秒。

参数
int $microseconds

时钟微秒

返回
static

setMinutes() ¶ public

setMinutes(int $minutes): static

设置时钟分钟。

参数
int $minutes

时钟分钟

返回
static

setSeconds() ¶ public

setSeconds(int $seconds): static

设置时钟秒。

参数
int $seconds

时钟秒

返回
static

setTime() ¶ public

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

设置时钟时间。

参数
int $hours 可选

时钟小时

int $minutes 可选

时钟分钟

int $seconds 可选

时钟秒

int $microseconds 可选

时钟微秒

返回
static

setToStringFormat() ¶ public static

setToStringFormat(string $format): void

设置转换为字符串时使用的默认格式。

参数
string $format

将来 __toString() 调用中使用的格式。

返回
void

toDateTimeImmutable() ¶ public

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

返回设置为此时钟时间的 DateTimeImmutable 实例。

参数
DateTimeZone|string|null $timezone optional

DateTimeImmutable 实例所在的时区

返回
DateTimeImmutable

toNative() ¶ public

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

返回设置为此时钟时间的 DateTimeImmutable 实例。

toDateTimeImmutable() 的别名。

参数
DateTimeZone|string|null $timezone optional

DateTimeImmutable 实例所在的时区

返回
DateTimeImmutable

属性详细信息

$ticks ¶ protected

类型
int

$toStringFormat ¶ protected static

用于 __toString 方法的格式。

类型
string
OpenHub
Pingping
Linode
  • 业务解决方案
  • 展示
  • 文档
  • 书籍
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 徽标和商标
  • 社区
  • 参与
  • 问题 (Github)
  • 烘焙坊
  • 特色资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 时事通讯
  • 领英
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • 帮助和支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成