convert string to specific datetime format?

前端 未结 7 696
孤城傲影
孤城傲影 2020-12-24 11:21

String

\"2011-05-19 10:30:14\"

To

Thu May 19 10:30:14 UTC 2011

How can I convert specific string to this

相关标签:
7条回答
  • 2020-12-24 12:21
    require 'date'
    
    date = DateTime.parse("2011-05-19 10:30:14")
    formatted_date = date.strftime('%a %b %d %H:%M:%S %Z %Y')
    

    See strftime() for more information about formatting dates.

    0 讨论(0)
提交回复
热议问题