Ruby:将字符串转换为日期 [英] Ruby: convert string to date

查看:849
本文介绍了Ruby:将字符串转换为日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Ruby中,将以下格式的字符串转换为日期的最佳方法是:{2009,4,15}

In Ruby, what's the best way to convert a string of the format: "{ 2009, 4, 15 }" to a Date?

推荐答案

您还可以使用 Date.strptime

Date.strptime("{ 2009, 4, 15 }", "{ %Y, %m, %d }")

这篇关于Ruby:将字符串转换为日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆