Ruby On Rails,周数不正确 (-1) [英] Ruby On Rails, week number is not the correct one (-1)

查看:44
本文介绍了Ruby On Rails,周数不正确 (-1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要当前周数,如果我没记错的话,现在是第 51 周?但是在控制台中测试时我得到了这个.

I need the current week number, if I'm not totally mistaken it's week 51 right now? However when testing it in the console I get this.

Time.now
=> 2013-12-19 11:08:25 +0100
Time.now.strftime('%U')
=> "50"

Date.today
=> Thu, 19 Dec 2013
Date.today.strftime("%U").to_i
=> 50

这是为什么?

推荐答案

Time.now.strftime('%V') 将根据 ISO 8601 为您提供周数.

Time.now.strftime('%V') will give you the week number according to ISO 8601.

这篇关于Ruby On Rails,周数不正确 (-1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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