4
A
回答
3
这是我发现:
require 'date'
local = DateTime.now
new_offset = Rational(0, 24) #put the offset you want as first argument
utc = local.new_offset(new_offset)
0
返回时间和UTC时间之间的偏移量,以秒为单位。
t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC
t.gmt_offset #=> 0
l = t.getlocal #=> 2000-01-01 14:15:01 -0600
l.gmt_offset #=> -21600
0
#As a string
t = Time.new(2011,6,27,14,10,0, "+07:00")
# or in seconds from UTC
t = Time.new(2011,6,27,14,10,0, 7*60*60)
相关问题
- 1. 时区偏移问题
- 2. 时区原偏移
- 3. PyOpenGL:glVertexPointer()偏移问题
- 4. Jquery偏移问题
- 5. jQuery:偏移问题
- 6. UIScrollview偏移问题
- 7. PostgreSQL更新时区偏移
- 8. java.timeTimeTimeFormatter时区偏移模式
- 9. 反向时区偏移量
- 10. 找出时区偏移量
- 11. 时区偏移计算
- 12. 时区在asp.net偏移
- 13. 忽略时区偏移量
- 14. Fullcalendar - 时区偏移量
- 15. FLEX:处理时区偏移
- 16. 获取时区偏移量
- 17. codeigniter获取时区偏移
- 18. jQuery.datepicker.formatDate和时区偏移
- 19. 包含时区偏移
- 20. Collectd时区偏移量
- 21. 时区偏移选择
- 22. 转换时区偏移小时数到时区偏移(军方?)小时
- 23. StackView插入偏移问题
- 24. JQuery的偏移问题
- 25. Gnuplot 4.4轴偏移问题
- 26. JQuery偏移量问题
- 27. Kafka Spark-Streaming偏移问题
- 28. IE偏移导航问题
- 29. jQuery动画/偏移问题
- 30. 在轨道上的ruby中是否有时区偏移错误?
但我怎么转换这个时间,例如偏移+7?我的问题是我想在特定的偏移量(明确指定)而不是UTC或机器本地时间获取星期几。所以当创建日期/时间obj时,我如何分配时区偏移量? – Mayumi