Home Ruby 把string转换成datetime
Post
Cancel

Ruby 把string转换成datetime

# 这个是 Rails的 model.to_json 后,产生的默认的日期格式

my_string = '2019-06-29T16:35:45.000+08:00'

DateTime.strptime(my_string, "%Y-%m-%dT%H:%M:%S.%L%z") 

This post is licensed under CC BY 4.0 by the author.