本地时区在 Ruby [英] Local Time Zone in Ruby

查看:58
本文介绍了本地时区在 Ruby的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要创建一个 Rails 应用程序,我想在其中获取本地时区的时间,即如果位置是 Delhi,则时区应该是 IST,如果位置是旧金山,时区应该是PDT.

Needs to create a Rails App where I want to get the time in local time Zone i.e. if the location is Delhi the time zone should be IST and if the the location is San Fransisco the time zone should be PDT.

如何在 ruby​​ on rails 中实现这一点?

How to accomplish this in ruby on rails?

附言一行代码,可根据位置自动设置时区.

P.S. One line code that can set the time zone automatically according to the location.

推荐答案

试试这个 Time.now.getlocal.zone

这篇关于本地时区在 Ruby的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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