post.created_at
)から時間を正しく抽出するにはどうすればよいですか? day
、month
、year
の値を抽出するには?どのようにカスタムパターンを介してday/month/year
を抽出する(可能です)?
post.created_at
)から時間を正しく抽出するにはどうすればよいですか? day
、month
、year
の値を抽出するには?どのようにカスタムパターンを介してday/month/year
を抽出する(可能です)?
文字列の形式で時刻:時、分、秒の値を取得するための http://ruby-doc.org/core/classes/Time.html#method-i-strftime
:strftime
ドキュメントの
post.created_at.strftime("FORMAT STRING HERE")
# Without the influence of time-zone: I take it that you want UTC
post.created_at.utc.strftime("FORMAT STRING HERE")
リンクロケールで
post.created_at.hour
post.created_at.min
post.created_at.sec
<%= l(@issue.created_at, format: :your_format) %>
YAML(app/config/locale/countr y_id.yml)あなたが宣言する必要があり
time:
formats:
your_format: '%d %b. %Y'
your_another_format: '%I:%M'
日付の書式設定が簡単に構成するためにあなたの国際化YAML定義ファイル内で宣言されなければならない、と他の日付形式は、ここで見つけることができます。
シュート、それはまさに私が必要なものです!ありがとう! – gmile
簡単な説明、サンプルコード、およびドキュメントへのリンク。星の答え! – Mizipzor
@mizipzor:ありがとう! – Swanand