8
8

More than 5 years have passed since last update.

Railsで"2013年9月21日"っていう文字をDateTime型に変換する

Last updated at Posted at 2013-09-17

javaだと、SimpleDateFormat使ってやるやつ。

require 'date'

p DateTime.strptime("2013年9月21日", "%Y年%m月%d日")
=> #<DateTime: 2013-09-21T00:00:00+00:00 ((2456557j,0s,0n),+0s,2299161j)>
8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8