How do I Convert DateTime.now to UTC in Ruby?

前端 未结 7 1490
既然无缘
既然无缘 2020-12-01 04:24

If I have d = DateTime.now, how do I convert \'d\' into UTC (with the appropriate date)?

7条回答
  •  情深已故
    2020-12-01 04:35

    DateTime.now.new_offset(0)
    

    will work in standard Ruby (i.e. without ActiveSupport).

提交回复
热议问题