Strftime 未更新到正确的日期

发布于 2025-01-02 09:41:19 字数 248 浏览 2 评论 0原文

我有一个 sinatra 应用程序,其中有一条小消息,我想说“快乐的“DayOfWeek””,但是我注意到它没有显示页面的正确日期,而是打印了前一个日期。 代码非常简单:

<%= "Happy #{Time.now.strftime("%A")}" %>

我以为这与请求响应周期有关,但是我切换了浏览器,在 chrome、firefox 和 safari 中都遇到了同样的问题。有人知道发生了什么事吗?

I have a sinatra app that has a small message that I want to say Happy "DayOfWeek" however I am noticing that it doesn't display the correct day for the page, it prints the previous one.
The code is extremely simple:

<%= "Happy #{Time.now.strftime("%A")}" %>

I thought it had something to do with the request response cycle, but I switched browsers and I got the same issue in chrome, firefox, and safari. Anyone have an idea of what is going on?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌能量女王 2025-01-09 09:41:19

摘自演示文稿的幻灯片 #28 Sinatra:最经典的原型 ,作者 Bryce Kerley,您会看到以下内容:

require 'sinatra'
require 'tzinfo'

mt = TZInfo::Timezone.get('America/New_York')

get '/time' do
  mt.now.strftime "%D %T"
end

应该可以做到。

from slide #28 of the presentation Sinatra: The Classiest of Prototypes, by Bryce Kerley, you see the following:

require 'sinatra'
require 'tzinfo'

mt = TZInfo::Timezone.get('America/New_York')

get '/time' do
  mt.now.strftime "%D %T"
end

that should do it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文