0

Ruby/Rails How to do this.

only modify the timezone of Time

2015-01-01 00:00:00 +0900  => 2015-01-01 00:00:00 +0000
JustWe
  • 4,250
  • 3
  • 39
  • 90

1 Answers1

-2

take this date in variable say currentDateTime:

then use following:

currentDateTime.change(:offset => "+0000")
Pramod S. Nikam
  • 4,271
  • 4
  • 38
  • 62
  • This doesn't work for a `Time` object. Only `DateTime`. – Joshua Pinter Oct 20 '18 at 13:52
  • I think it works with a `Time` instance, although it requires a slightly different formatting of the offset value: `+04:00` for `Time` instead of `+0400` for `Datetime`. – Adam Oct 09 '20 at 06:33