<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:36:03 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[CSHARP-185] DateTime timezone problem</title>
                <link>https://jira.mongodb.org/browse/CSHARP-185</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;Value inserted in database &lt;br/&gt;
2010-03-30 12:00:00 AM&lt;/p&gt;

&lt;p&gt;Value returned from database &lt;br/&gt;
2010-03-29 09:00:00 PM&lt;/p&gt;

&lt;p&gt;My Zone is +2GMT&lt;/p&gt;</description>
                <environment>Win7 SP1 x64 / VS.NET 2010 SP1 / C# 4.0&lt;br/&gt;
Driver Version 1.0.0.4098</environment>
        <key id="15371">CSHARP-185</key>
            <summary>DateTime timezone problem</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="robert@mongodb.com">Robert Stam</assignee>
                                    <reporter username="stefanprodan">Stefan Prodan</reporter>
                        <labels>
                    </labels>
                <created>Tue, 29 Mar 2011 22:09:36 +0000</created>
                <updated>Thu, 2 Apr 2015 18:27:58 +0000</updated>
                            <resolved>Wed, 30 Mar 2011 13:50:06 +0000</resolved>
                                    <version>1.0</version>
                                    <fixVersion>1.0</fixVersion>
                                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="502249" author="artoban" created="Thu, 20 Feb 2014 14:28:20 +0000"  >&lt;p&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;BsonDateTimeOptions(Kind = DateTimeKind.Local)&amp;#93;&lt;/span&gt;&lt;br/&gt;
 public DateTime Date &lt;/p&gt;
{ get; set; }  
&lt;p&gt;This is works nice for DateTime fields.&lt;br/&gt;
Sorry for trouble.&lt;/p&gt;</comment>
                            <comment id="502241" author="artoban" created="Thu, 20 Feb 2014 14:01:48 +0000"  >&lt;p&gt;I faced the problem of lack of time zone conversion to DateTime field when trying to save my objects in MongoDB ver. 2.4.5 using C # driver. In other words, the DateTime field stores (UTC / GMT). Mongo should handle the transition zone for DateTime field, but it is not happening. I have millions of records contains a DateTime field and performence is crucial for my case. I need competent answer  ASAP. My e-mail : trembovler@gmail.com. BR, Michael Trembovler&lt;/p&gt;</comment>
                            <comment id="27199" author="stefanprodan" created="Tue, 29 Mar 2011 23:54:29 +0000"  >&lt;p&gt;Thanks for your comments. I should have read the documentation more carefully before submitting this. &lt;br/&gt;
I apologies for wasting your time.&lt;/p&gt;</comment>
                            <comment id="27198" author="rstam" created="Tue, 29 Mar 2011 23:32:25 +0000"  >&lt;p&gt;When I set my timezone to Athens and run this program the output I get is:&lt;/p&gt;

&lt;p&gt;1. 3/30/2011 12:00:00 AM&lt;br/&gt;
2. 3/29/2011 09:00:00 PM&lt;/p&gt;

&lt;p&gt;These are the same time. The first time is in local Athens time, and the second time is in UTC.&lt;/p&gt;

&lt;p&gt;MongoDB stores all DateTimes in UTC. Any local times you supply are converted to UTC when stored in the database. The recommended approach is to always convert DateTime values to UTC yourself before storing them in the database, that way you are in full control.&lt;/p&gt;

&lt;p&gt;You can also tell the C# driver that you want to work in LocalTime, like this:&lt;/p&gt;

&lt;p&gt;        &lt;span class=&quot;error&quot;&gt;&amp;#91;BsonDateTimeOptions(Kind = DateTimeKind.Local)&amp;#93;&lt;/span&gt;&lt;br/&gt;
        public DateTime Date &lt;/p&gt;
{ get; set; }

&lt;p&gt;Note: watch out for FindOne! It doesn&apos;t necessarily return the same document you just inserted. If the collection has other documents it&apos;s hard to know which document you will get.&lt;/p&gt;</comment>
                            <comment id="27195" author="stefanprodan" created="Tue, 29 Mar 2011 22:53:39 +0000"  >&lt;p&gt;    &lt;span class=&quot;error&quot;&gt;&amp;#91;Serializable&amp;#93;&lt;/span&gt;&lt;br/&gt;
    public class MyData&lt;br/&gt;
    {&lt;br/&gt;
        &lt;span class=&quot;error&quot;&gt;&amp;#91;BsonId(IdGenerator = typeof(CombGuidGenerator))&amp;#93;&lt;/span&gt;&lt;br/&gt;
        public Guid Id &lt;/p&gt;
{ get; set; }&lt;br/&gt;
&lt;br/&gt;
        public DateTime Date { get; set; }
&lt;p&gt;    }&lt;/p&gt;

&lt;p&gt;    class Program&lt;br/&gt;
    {&lt;br/&gt;
        static void Main(string[] args)&lt;br/&gt;
        {&lt;br/&gt;
            //system time zone is (UTC+2:00) Athens, Bucharest, Istanbul&lt;/p&gt;

&lt;p&gt;            MongoServer srv = MongoServer.Create(new MongoConnectionStringBuilder()&lt;br/&gt;
            &lt;/p&gt;
{ Server = new MongoServerAddress(&quot;localhost&quot;, 27017) }
&lt;p&gt;);&lt;br/&gt;
            MongoDatabase db = srv&lt;span class=&quot;error&quot;&gt;&amp;#91;&amp;quot;Test&amp;quot;&amp;#93;&lt;/span&gt;;&lt;br/&gt;
            MongoCollection&amp;lt;MyData&amp;gt; col = db.GetCollection&amp;lt;MyData&amp;gt;(&quot;MyData&quot;);&lt;/p&gt;

&lt;p&gt;            var originalDate = new DateTime(2011, 3, 30, 0, 0, 0);&lt;br/&gt;
            Console.WriteLine(&quot;Original Value: &lt;/p&gt;
{0}&quot;, originalDate);&lt;br/&gt;
            //output: 3/30/2011 12:00:00 AM&lt;br/&gt;
&lt;br/&gt;
            col.Insert&amp;lt;MyData&amp;gt;(new MyData() { Date = originalDate });&lt;br/&gt;
            var mongoDate = col.FindOne().Date;&lt;br/&gt;
            Console.WriteLine(&quot;MongoDb Value: {0}
&lt;p&gt;&quot;, mongoDate);&lt;br/&gt;
            //output: 3/29/2011 10:43:26 PM !!!&lt;/p&gt;

&lt;p&gt;            Console.ReadLine();&lt;br/&gt;
        }&lt;br/&gt;
    }&lt;/p&gt;</comment>
                            <comment id="27189" author="rstam" created="Tue, 29 Mar 2011 22:17:17 +0000"  >&lt;p&gt;Can you provide some sample code showing how you inserted the value into the database?&lt;/p&gt;

&lt;p&gt;Also, can you tell me what time zone your machine is set to? You can get this from the Date and Time control panel. For example, mine is:&lt;/p&gt;

&lt;p&gt;(UTC-05:00) Eastern Time (US &amp;amp; Canada)&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrh97b:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>14290</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>