Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Fri Sep 23, 2011 2:40 am 
Offline

Joined: Mon Sep 19, 2011 4:46 pm
Posts: 1
WLM: leonelsantos.me@gmail.com
Location: Texas
I followed the instructions to setup the timezone on the server from the Getting Started with Linode guide.

I deployed a Rails App but I'm getting the times wrong on the created_at columns.

I go to rails console production and ran Time.now and I get the correct time.

I logged in to MySQL and ran SELECT NOW(); and I get the correct time.

But when a new record is created into the database I get that it's about 5am when it's really about 1am.

Anybody experience anything similar? How did you fix it?


Top
   
 Post subject:
PostPosted: Fri Sep 23, 2011 8:05 am 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
Does the "incorrect" time match the output of "date -u"? If so, it's probably storing times in UTC and displaying your local time zone to you. This is probably actually the "correct" behavior (as MySQL DATETIME columns do not have a timezone attribute IIRC), but it does need to be handled by your application or framework.

(Typically, the best approach to handling time is to store it in UTC, and convert to/from local time as close to the human as possible.)

_________________
Code:
/* TODO: need to add signature to posts */


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group