Installation and deployment Questions on installation, system configuration and deployment to the live server.
Version 4.x > Installation and deployment > Understanding timezone View modes: 
User avatar
Member
Member
Randar Puust - 5/5/2009 9:24:41 PM
   
Understanding timezone
Can you explain what parts of Kentico (publishing, version history, etc.) use the timezone? I took a shot at it, and it didn’t seem to affect anything.

Steps:
1. My OS time is EST.
2. I set the global system setting to GMT-5 EST, to match the OS. Clicked on Enable time zones.
3. Set the Site time zone for the Augustaclub site to GMT +7 Krasnoyarsk

So if I understand correct at this point, everything should be shifted by 12 (or 13) hours.

1. I went to the Form screen for a piece of content and clicked on Now for the Publish To time and it returned my current EST time, not 12 hours off.
2. I tried different publish From/To and it seems to be EST, not 12 hours off.

What is it's purpose?

User avatar
Member
Member
martinh - 5/6/2009 10:40:00 AM
   
RE:Understanding timezone
Hi Randar,

Actually, it is little more complicated than that, but just slightly. The time zone settings are set per controls on the document form. The server time zone is just a base for other time zones and does not affect any of the UI. Server time zone is the time zone in which is said that the values in the database are. Other time zones (web site, users, custom) are different level of time zones that you can use for specific things within Kentico CMS. Again, they are just some markers to differentiate the time shift between the server time zone and the selected one.

To customize the form properly, you need to apply some other settings to the time selector controls on the form. To do that, perform following additional steps:

1) Go to the properties of the document type in the Site manager -> Development -> Document types you want to configure for time zones, (e.g. News) and uncheck the option “Use publish from/publish to:”, that’s because you will need to override the field settings and you don’t want them to be automatic.

2) Go to the fields, and add two system fields (the gear wheel with plus icon) for Document attributes DocumentPublishFrom and DocumentPublishTo, both with calendar field type, and select the web site time zone in them.

3) From now on, when you go to the CMSDesk and edit the News document, you edit these fields in the web site time zone (shifted by 12 hours). They are saved to the database in the server time (shifted back) and should be published according to this.

4) You can do the same with any other date and time field and see how the value in the form changes when you change the time zone of the field in the document type definition.

The important thing here is that the time stored in the database is always the server time. That is why you need to convert it when you display it (this is what Kentico CMS currently does not in the other parts of UI of CMSDesk, like the last modified time or so, but it can be changed in the source code of the UI using methods below). And you will probably need to use the same functions in your transformations for the live site. These are located in the CMS.SiteProvider.TimeZoneHelper class, there is a lot of functions which can convert to specific time zones (user based, site based, server based, custom based) and there are also simplified versions of them in the transformations, so you would use in your transformation code like this:

<%# GetUserDateTime(Eval(“DocumentPublishFrom”)).ToString() %> to convert the server time (stored within the document) to the use time, or other specific methods,

or you can use method GetDateTime: <%# GetDateTime(Eval(“DocumentPublishFrom”)).ToString() %> which takes the settings from the closest parent component that can provide the ITimeZoneManager interface (web part or web part zone).

For the complete API of the TimeZoneHelper and the transformation methods (CMSAbstractTransformation) see our API documentation and hit me with any additional questions you will have on this.