stellarwp / dates
日期实用工具和类。
1.1.3
2024-09-11 17:26 UTC
Requires (Dev)
- codeception/module-asserts: ^1.0
- codeception/module-cli: ^1.0
- codeception/module-db: ^1.0
- codeception/module-filesystem: ^1.0
- codeception/module-phpbrowser: ^1.0
- codeception/module-rest: ^1.0
- codeception/module-webdriver: ^1.0
- codeception/util-universalframework: ^1.0
- lucatume/wp-browser: ^3.0.14
- phpunit/phpunit: ~6.0
- saggre/phpdocumentor-markdown: ^0.1.3
- symfony/event-dispatcher-contracts: ^2.5.1
- symfony/string: ^5.4
- szepeviktor/phpstan-wordpress: ^1.1
README
StellarWP团队编写的日期实用工具集合,免费提供给WordPress社区。
此工作是从在The Events Calendar中经过实战考验的日期处理中派生出来的!
安装
建议您通过Composer将Dates安装为项目依赖项。
composer require stellarwp/dates
我们实际上推荐使用Strauss将此库包含到您的项目中。
幸运的是,将Strauss添加到您的
composer.json
中比添加一个典型依赖项稍复杂一点,所以请查看我们的strauss文档。
文档
- 日期是如何构建的
- 常量
- 日期
- build_date_object -
mutable()
的别名 - build_localized_months
- build_localized_weekdays
- catch_and_throw
- clear_cache
- date -
date_only()
的别名 - date_diff -
diff()
的别名 - date_only
- datetime_from_format
- diff
- first_day_in_month
- get - 调用
immutable()
(默认)或mutable()
- get_cache
- get_first_day_of_week_in_month
- get_last_day_of_month
- get_last_day_of_week_in_month
- get_localized_months_full
- get_localized_months_short
- get_localized_weekdays_full
- get_localized_weekdays_initial
- get_localized_weekdays_short
- get_modifier_from_offset
- get_week_start_end
- get_weekday_timestamp
- has_cache
- hour -
hour_only()
的别名 - hour_only
- immutable
- interval
- is_after
- is_before
- is_between
- is_now - 使用不同的参数顺序调用
is_between()
,要查找的日期是最后一个是可选的。 - is_timestamp
- is_valid
- is_valid_date -
is_valid()
的别名 - is_weekday
- is_weekend
- last_day_in_month
- meridian -
meridian_only()
的别名 - meridian_only
- minutes
- minutes_only
- mutable
- number_to_ordinal
- range_coincides -
range_overlaps()
的别名 - range_overlaps
- reformat
- round_nearest_half_hour
- seconds -
seconds_only()
的别名 - 仅秒
- 设置缓存
- 排序
- 时间间隔
- 时间 -
time_only()
的别名 - 仅时间
- 转义日期格式
- 星期几结束
- wp_strtotime
- wp_locale_month
- wp_locale_weekday
- build_date_object -
- Date_I18n
- Date_I18n_Immutable
- 时区
日期是如何构建的
Dates::get()
方法接受多个参数(日期、时区、回退日期和不可变标志)。然而,您可以通过简单的调用Dates::get()
来获取当前日期和时间,如下所示
use StellarWP\Dates\Dates; $date = Dates::get();
无论您是使用这种简单的方法还是更复杂的方法,这里是在引擎盖下发生的事情