title: Crm DateTime issue in plugin
body: <p>I have a question relating to CRM DateTime problem. In opportunity form has custom DateTime field(Tender submission Date) that shows on form 'Date only' Format.
  And other string field (Tender Date) that modifies date  when Tender submission date changes. Let say...
  Tender submission date is 29/06/2011 12:00:00
  Tender Date should be 29/06/2012</p>
  <p>I create the plug-in for Create Post-operation and Update Pre-operation. I retrieves TenderSubDate.Day, Month and Year.<br />
  Crm Time zone is (GMT+08:00) Kuala Lumpur,Singapore then want to change (GMT-06:00) Central Time(US &amp; Canada).</p>
  <p>The problem is that when i update Tender date based on Tender submission date, the program return one day less than or grater than Tender sub date. Let say..</p>
  <p><strong>First Secnario</strong></p>
  <p>Tender submission date is 29/06/2012 12:00:00am</p>
  <p>Program returns <strong>28/06/2012</strong>(it's wrong and it should be 29/06/2012)</p>
  <p><strong>Second secnario</strong></p>
  <p>Tender submission date is 1/08/2012 12:00:00am</p>
  <p>Program returns <strong>32/07/2012</strong>(it's wrong and it should be 1/08/2012)</p>
  <p>what should i do in my program. please give me some idea. Here is my plug in code</p>
  <pre><code>public class TenderSubDateChange : IPlugin
  {
      #region Class Level Variables
      //IServiceProvider _serviceProvider;
      //IOrganizationServiceFactory _serviceFactory = null;
      //IOrganizationService _service = null;
      //IPluginExecutionContext _context = null;
  
      Entity _target = null;
      Entity _preImage = null;
      Entity _postImage = null;
      Guid _currentUser;
      #endregion
  
      #region  IPlugin Members
      public void Execute(IServiceProvider serviceProvider)
      {
          try
          {
              string message = null;
              IPluginExecutionContext _context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
  
              #region Organization Services
              // Obtain the organization service reference.
              IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
              IOrganizationService service = serviceFactory.CreateOrganizationService(_context.UserId);
              #endregion
  
              var ServiceContext = new OrganizationServiceContext(service);
  
              _currentUser = _context.UserId;
              message = _context.MessageName.ToLower();
  
              if (message == &quot;create&quot;)//message == &quot;create&quot; || 
              {
                  if (_context.InputParameters.Contains(&quot;Target&quot;) &amp;&amp; _context.InputParameters[&quot;Target&quot;] != null)
                      _target = (Entity)_context.InputParameters[&quot;Target&quot;];
  
                  if (_context.PreEntityImages.Contains(&quot;PreImage&quot;) &amp;&amp; _context.PreEntityImages[&quot;PreImage&quot;] != null)
                      _preImage = (Entity)_context.PreEntityImages[&quot;PreImage&quot;];
  
                  if (_context.PostEntityImages.Contains(&quot;PostImage&quot;) &amp;&amp; _context.PostEntityImages[&quot;PostImage&quot;] != null)
                      _postImage = (Entity)_context.PostEntityImages[&quot;PostImage&quot;];
  
                  DateTime hm_tenderdate;
                  if (_target.Attributes.Contains(&quot;hm_tendersubmissiondate&quot;))
                  {
                      hm_tenderdate = (DateTime)_target.Attributes[&quot;hm_tendersubmissiondate&quot;];
                      _target.Attributes[&quot;hm_tendersubdate&quot;] = (hm_tenderdate.Day) + &quot;/&quot; + hm_tenderdate.Month + &quot;/&quot; + hm_tenderdate.Year;
                      service.Update(_target);
                  }
              }
              if (message == &quot;update&quot;)//message == &quot;create&quot; || 
              {
                  if (_context.InputParameters.Contains(&quot;Target&quot;) &amp;&amp; _context.InputParameters[&quot;Target&quot;] != null)
                      _target = (Entity)_context.InputParameters[&quot;Target&quot;];
  
                  if (_context.PreEntityImages.Contains(&quot;PreImage&quot;) &amp;&amp; _context.PreEntityImages[&quot;PreImage&quot;] != null)
                      _preImage = (Entity)_context.PreEntityImages[&quot;PreImage&quot;];
  
                  if (_context.PostEntityImages.Contains(&quot;PostImage&quot;) &amp;&amp; _context.PostEntityImages[&quot;PostImage&quot;] != null)
                      _postImage = (Entity)_context.PostEntityImages[&quot;PostImage&quot;];
  
                  DateTime hm_tenderdate;
                  if (_target.Attributes.Contains(&quot;hm_tendersubmissiondate&quot;))
                  {
                      hm_tenderdate = (DateTime)_target.Attributes[&quot;hm_tendersubmissiondate&quot;];
                      _target.Attributes[&quot;hm_tendersubdate&quot;] = (hm_tenderdate.Day) + &quot;/&quot; + hm_tenderdate.Month + &quot;/&quot; + hm_tenderdate.Year;
                  }
              }
          }
          catch (Exception ex)
          {
              throw new InvalidPluginExecutionException(ex.Message, ex);
          }
      }
      #endregion
  }
  </code></pre>
  <p><img src="https://i.stack.imgur.com/gK8pz.png" alt="enter image description here" /></p>