# How to set a datetime to localtime?

**URL:** <https://www.ruby-forum.com/t/how-to-set-a-datetime-to-localtime/144887>\
**Category:** Rails\
**Created:** [August 4, 2008, 12:04am UTC](https://www.ruby-forum.com/t/how-to-set-a-datetime-to-localtime/144887 "2008-08-04T00:04:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [August 4, 2008, 12:04am UTC](https://www.ruby-forum.com/t/how-to-set-a-datetime-to-localtime/144887/1 "2008-08-04T00:04:22Z")

</div>

I would like to set the localtime, before validation. but if I write

before\_validation :start\_timing

def start\_timing  
s = self.starting\_at #params is 20008-10-31, no time  
self.starting\_at = Time.local(s.to\_date.year, s.to\_date.month,  
s.to\_date.day, 0, 0, 1)  
end

it doesn’t result in the correct localtime, giving 2008-10-31 23:00:01  
in the database which is 2 hours less  
(config.time\_zone = “Paris”)  
I would like 00:00:01 being set as the localtime…

how should I proceed ?

many thanks fyh
