This project is read-only.

Storing date times and displaying on client in correct local time zone

Dec 12, 2011 at 10:36 PM

Seems I have been very sheltered for the last 13 years of developing software systems. For the first time in my life I have to implement a system that spans multiple time zones.

I have done quite a bit of googling and reading up on the topic, but my head seems more confused, not less, as a result.

The problem:

The server / database is in 1 time zone.

The clients / browsers are in one or more different timezones.

Each client must see their date times in their own time zone.

One solution; store everything on the server in UCT, store each user's timezone, and dynamically transform for each request .

Then there is the whole SQL 2008 datetimeoffset type, and corresponding .Net DateTimeOffset, but that is messing with me.

I know this is not a Naked Objects specific problem, but it seems to complicate the issue. How do I display / store the dates across time zones  with NOF?

I'm hoping I am missing some really straight forward mechanism. This is such a pervasive requirement in the world and it must have been solved in a simple way that takes the pain out of it.

Any tips?

Dec 15, 2011 at 6:41 PM

Any kind and wise soul have a tip for me? :)

Dec 15, 2011 at 8:58 PM

One option would be to do the transformations (both ways) entirely in the client, using JavaScript  -  there may be some standard libraries for this (I have no idea).

Another option is to do it inside the domain model.  Say you have DateDue property.  Store this property on the server as UTC, but hide it from the user.  Instead display a derived Date property.  You'll then need to represent the current user in the model with details of their timezone, and then look this up when doing the transformation between the real and the derived due date.  If you aren't dealing with identified users then this approach isn't an option.

I'm not sure why Naked Objects complicates the issue  -  given that you say you haven't found any solution on how to solve this for, say, a regular ASP.NET MVC app.  My best advice is to post onto a much larger forum dealing with ASP.NET MVC.  If you can figure out how to do it there, then you'll have a startpoint for how to do it on Naked Objects MVC.

Dec 15, 2011 at 9:55 PM
Edited Dec 15, 2011 at 9:55 PM

The only reason why I say Naked Objects complicates things is because... well, I guess just because I probably haven't separated the concerns in my mind so well yet. :) I agree. I should first figure out how to solve it, before bringing NO into the picture.

Both your approaches sound promising. I will investigate and report back.

Thank you.

PS I think the whole DateTimeOffset typing thing confuses the heck out of me. Haven't yet found an explanation that cleared up the mud for my mind. (Or the mud in my mind)

Dec 15, 2011 at 10:40 PM
Can I ask: is it necessary for the clients in the different time-zones to interact with each other, or no?

If they do (eg it is a calendar scheduling system), then it would seem that you would want the server to hold the "canonical" date/time (eg UTC), and then have each client work out what that would be for their own timezone. In the case of NO MVC, it might be that the rendering of the date/time of an entity would need to be with respect to the timezone of the user making the request. You can certainly find out who the user is that is making the query, so I would imagine there might be a way to lookup their timezone.

If the clients in different timezones don't interact with each other, then I think you can forget about offsets etc; the fact that client who use a datetime of "21-Dec 9am" are actually referring to different times doesn't matter.

Hope that helps at least a little...


On 15 December 2011 18:41, jfbosch <> wrote:

From: jfbosch

Any kind and wise soul have a tip for me? :)

Read the full discussion online.

To add a post to this discussion, reply to this email (

To start a new discussion for this project, email

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at

Dec 15, 2011 at 11:44 PM

Hi Dan.

No, the users from different timezones do not have to interact. However, some events that generate a date occur on the server, and need to be displayed to the client appropriately. Similarly, some dates come in over simple web hooks from different timezones, and those again have to be stored on the server correctly and then displayed to the client correctly.

Thanx for your thoughts. The solution is slowly crystallising for me.

PS Remember to wipe the original email body when replying via email, else the online discussion gets cluttered. :)

Strange that CodePlex's email parser can't strip that out intelligently. :)

Dec 16, 2011 at 7:26 AM

On 15 December 2011 23:45, jfbosch <> wrote:

From: jfbosch

Thanx for your thoughts. The solution is slowly crystallising for me.

Good-o. Let us know where you end up.

PS Remember to wipe the original email body when replying via email, else the online discussion gets cluttered. :)

Ah... I've recently moved to using gmail exclusively (even abandoned Thunderbird), and such issues don't arise in gmail's threading. You can see that this time, at least, I've remembered ;-)


Dec 16, 2011 at 7:37 AM

Yes, I had to abandon my beloved Outlook Express about a year and a half ago when switching to Windows 7. I just could not find a client that worked for me, so starting using GMail exclusively also. I now don't know how I lived without it. It is absolutely brilliant. And the keyboard shortcuts make everything a snap.

(Sorry for going off topic a bit :))

Dec 16, 2011 at 7:41 AM
On 16 December 2011 07:37, jfbosch <> wrote:

(Sorry for going off topic a bit :))

Staying off-topic, I've just discovered gqueues, which integrates really well with gmail. I am finally getting my todo list organized. Recommended.

Dec 17, 2011 at 8:53 AM

I'm checking it out now. Tnx. :)