Liquid Snippets by ALSEL
📘 公式リファレンス🔧 リファレンス/フィルター初級

date フィルター(日付を指定形式でフォーマット)

日付値を指定されたフォーマット文字列に従って整形する。フォーマット文字列が空の場合は元の値がそのまま返される。入力が日付に変換できない場合も元の値が返される。

用途
注文日や商品作成日を「2024年1月15日」「15:30」のような指定の書式で表示したいとき。Shopify 管理画面やメールテンプレートで日付をストア独自の形式で出す。
設置場所
Liquid テンプレート内で `{{ date_value | date: '%Y年%m月%d日' }}` のように使う。%Y(年4桁)、%m(月2桁)、%d(日2桁)など各フォーマット指定子を組み合わせて目的の書式を作成する。
注意点
%U と %W は週番号の計算開始日が異なるため(%U は日曜日、%W は月曜日)、どちらを使うかストア運用に合わせて選ぶ必要がある。タイムゾーン名(%Z)は環境により表示されないことがあるため、協定世界時(UTC)からのオフセット表示が必要な場合は別途実装する。フォーマット指定子の大文字・小文字は厳密に区別される。
タグ:datetimeformatfilter

仕様

19 行 / json
{
  "category": "date",
  "deprecated": false,
  "deprecation_reason": "",
  "description": "This filter formats a date using various format specifiers. If the format string is empty,\nthe original input is returned. If the input cannot be converted to a date, the original input is returned.\n\nThe following format specifiers can be used:\n\n%a - The abbreviated weekday name (``Sun'')\n%A - The  full  weekday  name (``Sunday'')\n%b - The abbreviated month name (``Jan'')\n%B - The  full  month  name (``January'')\n%c - The preferred local date and time representation\n%d - Day of the month (01..31)\n%H - Hour of the day, 24-hour clock (00..23)\n%I - Hour of the day, 12-hour clock (01..12)\n%j - Day of the year (001..366)\n%m - Month of the year (01..12)\n%M - Minute of the hour (00..59)\n%p - Meridian indicator (``AM''  or  ``PM'')\n%s - Number of seconds since 1970-01-01 00:00:00 UTC.\n%S - Second of the minute (00..60)\n%U - Week  number  of the current year,\n        starting with the first Sunday as the first\n        day of the first week (00..53)\n%W - Week  number  of the current year,\n        starting with the first Monday as the first\n        day of the first week (00..53)\n%w - Day of the week (Sunday is 0, 0..6)\n%x - Preferred representation for the date alone, no time\n%X - Preferred representation for the time alone, no date\n%y - Year without a century (00..99)\n%Y - Year with century\n%Z - Time zone name\n%% - Literal ``%'' character",
  "parameters": [],
  "return_type": [
    {
      "type": "string",
      "name": "",
      "description": "",
      "array_value": ""
    }
  ],
  "examples": [],
  "summary": "Formats a date according to a specified format string.",
  "syntax": "date | date: string",
  "name": "date"
}

出典・ライセンス

License:
MIT

このコードは Shopify 著作の MIT ライセンスソースです。 原本の著作権は Shopify が保有します。日本語訳は ALSEL によるものです。

関連項目

📘 公式リファレンス🔧 リファレンス/フィルター初級

avatar フィルター(顧客アバター画像HTML生成)

顧客アバターが存在する場合、それを表示する HTML タグを生成するフィルター。customer オブジェクトに対して使用する。

📁 theme-liquid-docs·MIT·19
📘 公式リファレンス🔧 リファレンス/フィルター初級

default_errors フィルター(フォーム送信エラーを日本語化)

form.errors の各エラーコードに対応する既定のエラーメッセージを自動生成するフィルター。フォーム送信時の入力値不正や必須項目空白などのエラーを言語別に出力する。

📁 theme-liquid-docs·MIT·19
📘 公式リファレンス🔧 リファレンス/フィルター初級

payment_terms フィルター(Shop Pay分割払いバナーを生成)

product フォームまたは cart フォームに対して使用し、Shop Pay の分割払いオプションを表示するための HTML を生成するフィルター。顧客が購入時に分割払いプランを選択できるようにする。

📁 theme-liquid-docs·MIT·19
📘 公式リファレンス🔧 リファレンス/フィルター初級

abs フィルター(数値の絶対値を取得)

負の数を正の数に変換する。数値の絶対値(ゼロからの距離)を返すフィルター。

📁 theme-liquid-docs·MIT·30
📘 公式リファレンス🔧 リファレンス/フィルター初級

append フィルター(文字列の末尾に追加)

文字列の末尾に別の文字列を連結するフィルター。URL パスの結合やテキストの接尾辞追加に使う。

📁 theme-liquid-docs·MIT·30
📘 公式リファレンス🔧 リファレンス/フィルター初級

asset_url フィルター(CDN URLを取得)

テーマの assets ディレクトリ内のファイル(CSS、JavaScript、画像など)に対する Shopify CDN の絶対 URL を返すフィルター。

📁 theme-liquid-docs·MIT·30