Reputation: 4774
My current Time
object looks like that:
2015-01-10 17:13:00.000000000 +0000
While I need it to look like that:
2015-01-10 18:13:00.000000000 +0100
I'd like to just set a value of timezone offset to receive that, without knowing names of timezones in strings, somethig like:
my_date.set_timezone_offset(1)
How could I do that?
Upvotes: 0
Views: 1820
Reputation: 2398
So to change the Time depending by the given offset, you have to use new_offset
method which is part of DateTime
(not sure if this works this Time
objects, if not you can try to parse it):
time = "2015-01-10 17:13:00.000000000 +0000".to_datetime
Then use the method:
time.new_offset("+10:00")
This will return DateTime with provided offset also changed time according to that offset.
Upvotes: 2
Reputation: 15045
DateTime.now.change(offset: "+0100")
Returns datetime with provided offset
Upvotes: 1