你怎么说“x分钟前”发生了什么事?或“x小时前”或“x天前”在Ruby中? [英] How do you say something happened "x minutes ago" or "x hours ago" or "x days ago" in Ruby?

查看:150
本文介绍了你怎么说“x分钟前”发生了什么事?或“x小时前”或“x天前”在Ruby中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在Ruby中有一个时间变量,我怎么能说它是指发生下列事件之一:

x分钟前或x小时前或x天前



很明显,如果两天前发生了什么事情,我不想说这是在几分钟前发生的事情。

解决方案

如果您在rails上:

  time_ago_in_words 


If I have a time variable in Ruby, how could I say that it refers to an event that happened one of the following:

"x minutes ago" or "x hours ago" or "x days ago"

Obviously if something happened 2 days ago, I would not want to say it happened such-and-such minutes ago.

解决方案

If you are on rails:

time_ago_in_words

这篇关于你怎么说“x分钟前”发生了什么事?或“x小时前”或“x天前”在Ruby中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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