updated_at with client time not server time

Hi,

I use the t.timestamps that are automatically added by rails. So there is the created_at and updated_at columns in the DB.

When I create an entry those are filled with the server time when the request is created or updated.

I want that to be the client time, if I do the request from Europe now I get US time in the DB.

How to do it? Do I need to send explicitely time info from the client with JS for example or can I check from the request at server side? Any practical examples?

Thanks.

Have a look at timezone support in Rails 2.1. You'll be able to keep the timestamps based on the time on the server (as they should be anyway), and you'll be able to show data in the timezone of the client.

Regards, Craig

Thanks Craig I'll take a look. Of course I can convert those to client time, what was I thinking of 8-P

Cheers!

Hmmm. My users do not select a time zone and I am not planning to ask them to provide it for some reasons. I should be able to provide the client time, I guess I'll need to use some javascript to get the local time and store it at server side. That is mostly ok but clients running on mobile might be unable to us js...

Regards

comopasta Gr wrote:

Hmmm. My users do not select a time zone and I am not planning to ask them to provide it for some reasons. I should be able to provide the client time, I guess I'll need to use some javascript to get the local time and store it at server side. That is mostly ok but clients running on mobile might be unable to us js...

Jumping in late: Isn't either your timezone, or a hint, available in standard HTTP headers??

Otherwise, asks DNS-land where their IP looks like it is. If they spoofed it, that's on them...

Dilbert changes around midnight for me, for example. I have not checked this phenom from other time zones...

Hi,

Yeah I was checking the requests that the client sends. There are no hints about client's time zone. In the reply from the server the date is shown but not in the request from the client.

I continued searching and there's been similar questions in the forum:

Javascript seems to be the only choice. Getting location based on IP would be good but will slow down the app and is not so accurate.

Regards