{"id":166,"date":"2015-11-12T13:02:47","date_gmt":"2015-11-12T13:02:47","guid":{"rendered":"http:\/\/www.softreeconsulting.com\/?p=166"},"modified":"2015-11-12T13:02:47","modified_gmt":"2015-11-12T13:02:47","slug":"convert-utc-time-to-web-time-zone-format-presents-in-sharepoint-site","status":"publish","type":"post","link":"https:\/\/softreetechnology.com\/blog\/sharepoint\/convert-utc-time-to-web-time-zone-format-presents-in-sharepoint-site\/","title":{"rendered":"Convert any time format to web time zone format presents in SharePoint site"},"content":{"rendered":"<p>Generally Last modified time of SharePoint site or SharePoint list or SharePoint list item is in UTC (Universal Time Coordinated) format and if SharePoint time zone format is not UTC format then result of last modified time such as (<span style=\"color: #339966;\">web.LastItemModifiedDate<\/span>) seems incorrect.<\/p>\n<p>So it has to convert time into correct format of sharepoint web time zone.<\/p>\n<p>Steps:-<\/p>\n<ol>\n<li>Add reference \u201cMicrosoft.sharepoint.client.dll\u201d and \u201cMicrosoft.sharepoint.client.Runtime.dll\u201d.<\/li>\n<li>Add namespace usingSharePoint.Client and<\/li>\n<\/ol>\n<p>using Microsoft.SharePoint.Client.Utilities;<\/p>\n<p>&nbsp;<\/p>\n<p>using System;<\/p>\n<p>using System.Collections.Generic;<\/p>\n<p>using Microsoft.SharePoint.Client;<\/p>\n<p>using Microsoft.SharePoint.Client.Utilities;<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #0000ff;\">namespace<\/span> ConsoleApplication10<\/p>\n<p>{<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #0000ff;\">class<\/span> <span style=\"color: #29abab;\">Program<\/span><\/p>\n<p style=\"padding-left: 30px;\">{<\/p>\n<p style=\"padding-left: 60px;\"><span style=\"color: #0000ff;\">static<\/span> <span style=\"color: #0000ff;\">void<\/span> Main(<span style=\"color: #0000ff;\">string<\/span>[] args)<\/p>\n<p style=\"padding-left: 60px;\">{<\/p>\n<p style=\"padding-left: 90px;\"><span style=\"color: #0000ff;\">string<\/span> webLastModified = <span style=\"color: #0000ff;\">string<\/span>.Empty;<\/p>\n<p style=\"padding-left: 90px;\"><span style=\"color: #0000ff;\">using<\/span> (<span style=\"color: #29abab;\">ClientContext<\/span> ctx=<span style=\"color: #0000ff;\">new<\/span> <span style=\"color: #29abab;\">ClientContext<\/span>(<span style=\"color: #800000;\">&#8220;SiteUrl&#8221;<\/span>))<\/p>\n<p style=\"padding-left: 90px;\">{<\/p>\n<p style=\"padding-left: 120px;\">\u00a0<span style=\"color: #008000;\"> \/\/Apply Credential<\/span><\/p>\n<p style=\"padding-left: 120px;\">ctx.Credentials = <span style=\"color: #0000ff;\">new<\/span> System.Net.<span style=\"color: #29abab;\">NetworkCredential<\/span>(<span style=\"color: #800000;\">&#8220;UserName&#8221;<\/span>, <span style=\"color: #800000;\">&#8220;Password&#8221;<\/span>);<\/p>\n<p style=\"padding-left: 120px;\"><span style=\"color: #29abab;\">Web<\/span> web = ctx.Web;<\/p>\n<p style=\"padding-left: 120px;\">\u00a0ctx.Load(web);<\/p>\n<p style=\"padding-left: 120px;\">ctx.ExecuteQuery();<\/p>\n<p style=\"padding-left: 120px;\"><span style=\"color: #008000;\">\/\/Gives time in UTC Format<\/span><\/p>\n<p style=\"padding-left: 120px;\"><span style=\"color: #29abab;\">DateTime<\/span> timeUtc = web.LastItemModifiedDate;<\/p>\n<p style=\"padding-left: 120px;\"><span style=\"color: #008000;\">\/\/Convert to sharepoint web format<\/span><\/p>\n<p style=\"padding-left: 120px;\">\u00a0\u00a0<span style=\"color: #29abab;\">ClientResult<\/span>&lt;<span style=\"color: #0000ff;\">string<\/span>&gt; dateTime = <span style=\"color: #29abab;\">Utility<\/span>.FormatDateTime(ctx, web, timeUtc, \u00a0\u00a0\u00a0<span style=\"color: #29abab;\">DateTimeFormat<\/span>.DateTime);<\/p>\n<p style=\"padding-left: 120px;\">ctx.ExecuteQuery();<\/p>\n<p style=\"padding-left: 120px;\">\u00a0webLastModified = dateTime.Value;<\/p>\n<p style=\"padding-left: 90px;\">}<\/p>\n<p style=\"padding-left: 60px;\">}<\/p>\n<p style=\"padding-left: 30px;\">}<\/p>\n<p>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Generally Last modified time of SharePoint site or SharePoint list or SharePoint list item is in UTC (Universal Time Coordinated) format and if SharePoint time zone format is not UTC format then result of last modified time such as (web.LastItemModifiedDate) seems incorrect. So it has to convert time into correct format of sharepoint web time zone. Steps:- Add reference \u201cMicrosoft.sharepoint.client.dll\u201d [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[47,48,49],"class_list":["post-166","post","type-post","status-publish","format-standard","hentry","category-sharepoint","tag-convert-any-time-format-to-web-time-zone-format-presents-in-sharepoint-site","tag-convert-time-according-to-sharepoint-site-regional-setting","tag-convert-time-according-to-sharepoint-site-time-zone"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Convert any time format to web time zone format presents in SharePoint site - Softree Technology<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/softreetechnology.com\/blog\/sharepoint\/convert-utc-time-to-web-time-zone-format-presents-in-sharepoint-site\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Convert any time format to web time zone format presents in SharePoint site - Softree Technology\" \/>\n<meta property=\"og:description\" content=\"Generally Last modified time of SharePoint site or SharePoint list or SharePoint list item is in UTC (Universal Time Coordinated) format and if SharePoint time zone format is not UTC format then result of last modified time such as (web.LastItemModifiedDate) seems incorrect. So it has to convert time into correct format of sharepoint web time zone. Steps:- Add reference \u201cMicrosoft.sharepoint.client.dll\u201d [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/softreetechnology.com\/blog\/sharepoint\/convert-utc-time-to-web-time-zone-format-presents-in-sharepoint-site\/\" \/>\n<meta property=\"og:site_name\" content=\"Softree Technology\" \/>\n<meta property=\"article:published_time\" content=\"2015-11-12T13:02:47+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Convert any time format to web time zone format presents in SharePoint site - Softree Technology","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/softreetechnology.com\/blog\/sharepoint\/convert-utc-time-to-web-time-zone-format-presents-in-sharepoint-site\/","og_locale":"en_US","og_type":"article","og_title":"Convert any time format to web time zone format presents in SharePoint site - Softree Technology","og_description":"Generally Last modified time of SharePoint site or SharePoint list or SharePoint list item is in UTC (Universal Time Coordinated) format and if SharePoint time zone format is not UTC format then result of last modified time such as (web.LastItemModifiedDate) seems incorrect. So it has to convert time into correct format of sharepoint web time zone. Steps:- Add reference \u201cMicrosoft.sharepoint.client.dll\u201d [&hellip;]","og_url":"https:\/\/softreetechnology.com\/blog\/sharepoint\/convert-utc-time-to-web-time-zone-format-presents-in-sharepoint-site\/","og_site_name":"Softree Technology","article_published_time":"2015-11-12T13:02:47+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/convert-utc-time-to-web-time-zone-format-presents-in-sharepoint-site\/#article","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/convert-utc-time-to-web-time-zone-format-presents-in-sharepoint-site\/"},"author":{"name":"admin","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b"},"headline":"Convert any time format to web time zone format presents in SharePoint site","datePublished":"2015-11-12T13:02:47+00:00","mainEntityOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/convert-utc-time-to-web-time-zone-format-presents-in-sharepoint-site\/"},"wordCount":180,"commentCount":1,"publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"keywords":["Convert any time format to web time zone format presents in SharePoint site","convert time according to sharepoint site regional setting","convert time according to sharepoint site time zone"],"articleSection":["SharePoint"],"inLanguage":"en","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/softreetechnology.com\/blog\/sharepoint\/convert-utc-time-to-web-time-zone-format-presents-in-sharepoint-site\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/convert-utc-time-to-web-time-zone-format-presents-in-sharepoint-site\/","url":"https:\/\/softreetechnology.com\/blog\/sharepoint\/convert-utc-time-to-web-time-zone-format-presents-in-sharepoint-site\/","name":"Convert any time format to web time zone format presents in SharePoint site - Softree Technology","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/#website"},"datePublished":"2015-11-12T13:02:47+00:00","breadcrumb":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/convert-utc-time-to-web-time-zone-format-presents-in-sharepoint-site\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/softreetechnology.com\/blog\/sharepoint\/convert-utc-time-to-web-time-zone-format-presents-in-sharepoint-site\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/convert-utc-time-to-web-time-zone-format-presents-in-sharepoint-site\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/softreetechnology.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Convert any time format to web time zone format presents in SharePoint site"}]},{"@type":"WebSite","@id":"https:\/\/softreetechnology.com\/blog\/#website","url":"https:\/\/softreetechnology.com\/blog\/","name":"Softree Technology","description":"Celebrating 10+ Years in SharePoint Consulting !","publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/softreetechnology.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en"},{"@type":"Organization","@id":"https:\/\/softreetechnology.com\/blog\/#organization","name":"Softree Technology","url":"https:\/\/softreetechnology.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","contentUrl":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","width":844,"height":230,"caption":"Softree Technology"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b","name":"admin","image":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/softreeconsulting.com"],"url":"https:\/\/softreetechnology.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/166","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/comments?post=166"}],"version-history":[{"count":0,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/166\/revisions"}],"wp:attachment":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/media?parent=166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/categories?post=166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/tags?post=166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}