pronamic / wp-datetime
WordPress DateTime 库。
v2.1.7
2023-10-30 10:15 UTC
Requires
- php: >=7.4
Requires (Dev)
- automattic/wordbless: ^0.4.1
- bamarni/composer-bin-plugin: ^1.4
- koodimonni-language/de_de: *
- koodimonni-language/en_gb: *
- koodimonni-language/fr_fr: *
- koodimonni-language/ja: *
- koodimonni-language/nl_nl: *
- overtrue/phplint: ^9.0
- php-coveralls/php-coveralls: ^2.4
- php-stubs/wordpress-globals: ^0.2.0
- phpmd/phpmd: ^2.9
- pronamic/pronamic-cli: ^1.1
- pronamic/wp-coding-standards: ^2.0
- roots/wordpress: ^6.0
- yoast/phpunit-polyfills: ^2.0
README
WordPress 过滤器
pronamic_datetime_default_format
function prefix_pronamic_datetime_default_format( $format ) { return _x( 'D j M Y \a\t H:i', 'default datetime format', 'pronamic-ideal' ); } add_filter( 'pronamic_datetime_default_format', 'prefix_pronamic_datetime_default_format' );
注意 date_i18n
需要注意的是,date_i18n()
- 与
date()
并不完全兼容,并非所有格式都受到支持(例如缩写格式); - 不接受 Unix 时间戳(尽管文档中有说明),期望的值是“WordPress 时间戳”(偏移时区);
- 与某些时区设置有问题,例如数值时区;
- 在正常情况下,对
$gmt
参数不做任何处理;
必须仔细审核该函数的使用,确保正确性,尤其是关于时区输出的部分。
来源: https://developer.wordpress.org/reference/functions/date_i18n/#comment-2403