Using And Converting Date, Time And Timezone In Microsoft Windows Sharepoint Services 3.0

This topic includes many of the “how-to” and walk-through topics for time using and time zone functions in Microsoft Windows SharePoint Services 3.0.

Do the following on each SharePoint site on which you want to change the default regional settings:1.    Open the site on which you want to change the default regional settings.2.    Click Site Settings in the Site Actions menu Note   On a site for which the Site Actions menu is customized, point to Site Settings, and then click the settings that you want to view.3.    On the Site Settings page, under Site Administration, click Regional settings.4.    On the Regional Settings page, select the settings that you want for this site, and then click OK.

You will have trouble getting the current time in a SharePoint Designer workflow when testing against a date/time field of the current item, because SharePoint returns 12:00 AM as the time.

To get the current time, you can use “Set DateTime constant” activity from Virto SharePoint Workflow Activities Kit.

This activity allows setting DateTime constant Now to variable and you can use correct time in other workflow actions.

SharePoint Designer workflow doesn’t allow getting the current date and time on this computer, expressed as the Coordinated Universal Time (UTC).To get the current time, you can use “Set DateTime constant” activity from Virto SharePoint Workflow Activities Kit.

This activity allows setting DateTime constant UtcNow to variable and you can use correct time in other workflow actions.

SharePoint Designer workflow doesn’t allow getting the custom predefined time and time on this computer, expressed as the Coordinated Universal Time (UTC).To get the custom predefined time, you can use “Set DateTime constant” activity from Virto SharePoint Workflow Activities Kit. This activity allows setting Date Time constant: Now, Utc Now, Today, Yesterday, Tomorrow, Begin of this Week, End of this Week and etc. to variable.

The activity stores time constant to variable and you can use correct time in other workflow actions. The tables below shows all constant, description and sample result if current time is 12 February 2010 16:20 (UTC+2:00).

.style1 { border: 1px solid #666666; }

Name Description Example Now The current date and time on this computer, expressed as the local time. 12 February 2010 16:20 UtcNow The current date and time on this computer, expressed as the Coordinated Universal Time (UTC). 12 February 2010 15:20 Today Current date. 12 February 2010 00:00 Yesterday Yesterday date. 11 February 2010 00:00 Tomorrow Tomorrow date 13 February 2010 00:00 Begin of this week Begin of this WeekNote: Sunday is the first day of the week. 7 February 2010 00:00 End of this week End of this WeekNote: Saturday is the last day of the week 13 February 2010 23:59 Begin on this month Begin on the month 1 February 2010 00:00 End on this month End on this month. 28 February 2010 23:59 Begin of this year Begin of this year 1 January 2010 00:00 End of this year End of this year 31 December 2010 23:59

SharePoint Workflow Designer PhraseSet DateTime constant Now to variable.

Parameter – Now

Description

One of date time constant: •    Now•    UtcNow•    Today•    Yesterday•    Tomorrow•    Begin of this Week•    End of this Week•    Begin of this Month•    End of this Month•    Begin of this Year•    End of this Year

To convert local time to the UTC, you can use “Converts Date from Local Time to UTC” activity from Virto SharePoint Workflow Activities Kit. This activity allows converting the value of the current DateTime variable from local time in specified Time Zone to Coordinated Universal Time (UTC).

You can specify custom time zone or use time zone from current site.

SharePoint Workflow Designer PhraseConverts local time from Local Time in [Current Site] time zone to UTC and store result in utc_time.

Parameter Description local_time Date Time variable. [Current Site] Optional. Time zone. Default value is current site time zone, but you can select you custom time zone.

To convert UTC time to the Local Time, you can use “Converts Date from UTC to Local Time” activity from Virto SharePoint Workflow Activities Kit. This activity allows converting the value of the current DateTime variable from to Coordinated Universal Time (UTC) to local time in specified Time Zone.

You can specify custom time zone or use time zone from current site.

SharePoint Workflow Designer PhraseConverts utc time from UTC to time zone in [Current Site] time zone and store result in utc_time.Parameters

Parameter Description local_time Date Time variable. [Current Site] Optional. Time zone. Default value is current site time zone, but you can select you custom time zone.

To convert UTC time to the Local Time, you can use “Set Date constant” and “Converts DateTime from UTC to Local Time” activities from Virto SharePoint Workflow Activities Kit.You should call “Set DateTime constant” activity and store UTC time to variable, then call “Converts DateTime from UTC to Local Time” activity to convert UTC time to local time. See screenshot below.

To get string from Date Time with Time Zone information you can use “Convert DateTime to Text” activity from Virto SharePoint Workflow Activities Kit.If pass “MM/dd/yyyy hh:mm:ss (zzz)” as format, activity will store “02.16.2010 02:33:34 (-05:00)” to text variable.

If you are using the Versions property of the SPListItem class to return the collection of versions for a list item, you should know that all time SPListItemVersion properties would be returned in UTC format. You should correctly convert them to the current time zone. To do this use SPTimeZone .UTCToLocalTime method to retrieve the current local date and time. The code shows how to compare two dates:/ / First get the current SPTimeZone of SPWeb:SPTimeZone timeZone = web.RegionalSettings.TimeZone;/ / Convert date and time in local:DateTime localDT = timeZone.UTCToLocalTime (previousDate);if (newDate! = localDT)( …)

The link below shows solution for requirement to staple a feature to site templates so that despite the server living in Perth, east coast users would have their time-zone set correctly for the site they were creating.

This link below describes how to update manually the daylight saving time (DST) period for a time zone definition in Microsoft Windows SharePoint Services 3.0 and in Microsoft Windows SharePoint Services 2.0 by modifying the Timezone.xml file. Windows SharePoint Services uses the Timezone.xml file to store time zone information. The Timezone.xml file includes the start date and time for daylight saving time and for standard time for a specific time zone.

Some stuffs you might like:

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
Related Posts:

This entry was filed under Local Dating. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


Leave a Reply

You must be logged in to post a comment.