[WordPress] 外掛分享: TK Timestamp to Human Readable Date

首頁外掛目錄 › TK Timestamp to Human Readable Date
10+
安裝啟用
尚無評分
2249 天前
最後更新
問題解決
WordPress 4.5+ PHP 7.1.0+ v1.0.1 上架:2020-01-21

內容簡介

所有可用的短碼參數

'timestamp' => '', // 或使用 'post_id' 和 'field_timestamp' 參數
'format' => 'c', // 參見 https://www.php.net/manual/en/function.date.php
'time_zone' => '', // 預設為 WP 的一般設定時區(如果是有效的 PHP 時區),否則為 UTC。僅支援 PHP 命名時區 - 參見 https://www.php.net/manual/en/timezones.php
'field_name' => '', // 原始名稱(包括 `wpcf-` 前綴(如果是 Types 欄位))或應具有 UTC 時間戳記作為其值的自訂欄位
'post_id' => '', // 如果使用 'field_timestamp' 參數,則適用於目前文章 - 如果為空,則預設為當前文章

短碼範例

1)
短碼: [tk_timestamp_human timestamp="1608299220"]

(假設您的 WordPress 一般設定時區設為 ‘Europe/Amsterdam’)
預期結果: 2020-12-18T14:47:00+01:00

2)
短碼: [tk_timestamp_human timestamp="1608299220" time_zone="America/Chicago"]

預期結果: 2020-12-18T07:47:00-06:00

3)
短碼: [tk_timestamp_human timestamp="1608299220" time_zone="UTC"]

預期結果: 2020-12-18T13:47:00+00:00

4)
短碼: [tk_timestamp_human timestamp="1608299220" time_zone="America/Chicago" format="j F, Y"]

預期結果: 18 December, 2020

全域函數

tk_timestamp_to_human_wp_all_export() 全域函數可用作短碼的包裝器,使用其所有預設值,除了要求時間戳記參數以及可以選擇傳遞格式和時區參數。

這對於使用 WP All Export(http://www.wpallimport.com/tour/export-developer-friendly/)非常有用,例如將自訂欄位以 UTC 時間戳記值匯出為易於閱讀的格式,例如如果您要移動數據的系統需要特定格式。

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.0.1) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「TK Timestamp to Human Readable Date」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

All Available Shortcode Arguments

'timestamp' => '', // or use the 'post_id' and 'field_timestamp' arguments
'format' => 'c', // see https://www.php.net/manual/en/function.date.php
'time_zone' => '', // defaults to WP's General Settings time zone (if valid PHP time zone), else UTC. Only supports a PHP named time zone -- see https://www.php.net/manual/en/timezones.php
'field_name' => '', // the raw name (including the `wpcf-` prefix if a Types field) or a custom field that should have a UTC timestamp as its value
'post_id' => '', // applicable if using the 'field_timestamp' argument - defaults to current post if empty

Shortcode Examples
1)
Shortcode: [tk_timestamp_human timestamp="1608299220"]
(Assuming your WordPress General Settings time zone is set to ‘Europe/Amsterdam’)
Expected Result: 2020-12-18T14:47:00+01:00
2)
Shortcode: [tk_timestamp_human timestamp="1608299220" time_zone="America/Chicago"]
Expected Result: 2020-12-18T07:47:00-06:00
3)
Shortcode: [tk_timestamp_human timestamp="1608299220" time_zone="UTC"]
Expected Result: 2020-12-18T13:47:00+00:00
4)
Shortcode: [tk_timestamp_human timestamp="1608299220" time_zone="America/Chicago" format="j F, Y"]
Expected Result: 18 December, 2020
Global Function
The tk_timestamp_to_human_wp_all_export() global function is available as a wrapper for the shortcode, using all its defaults except requiring the Timestamp argument and optionally passing the Format and Time Zone parameters.
This can be handy for using with WP All Export (http://www.wpallimport.com/tour/export-developer-friendly/), such as to export a custom field that’s a UTC timestamp value to a human-readable format, such as if the system you’re moving the data to requires a specific format.

延伸相關外掛

文章
Filter
Mastodon