[CLOSED] JSON is using the user's current time zone when converting a DateTime

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] JSON is using the user's current time zone when converting a DateTime

    I found an issue regarding the DateTime conversion by Json. I have a GridPanel with a date column but when i run the example my current time zone is -3:00 (Brazil) is applied to the value of date column.

    Click image for larger version. 

Name:	ex00001.png 
Views:	73 
Size:	19.8 KB 
ID:	6153

    It was supposed to be 09:14:..

    Note: i found another thread regarding this issue, but i think that it's incomplete: http://forums.ext.net/showthread.php...-Date-Timezone

    1 - View
    <ext:GridPanel ID="GridPanel1" runat="server" Title="Records">
        <Store>
            <ext:Store runat="server" ID="Store2">
                <Proxy>
                    <ext:AjaxProxy Url="/Example/LoadFakeRecords/">
                        <ActionMethods Read="POST" />
                        <Reader>
                            <ext:JsonReader Root="data" />
                        </Reader>
                    </ext:AjaxProxy>
                </Proxy>
                <Model>
                    <ext:Model ID="Model2" runat="server">
                        <Fields>
                            <ext:ModelField Name="ID" Type="String" />
                            <ext:ModelField Name="Name" Type="String" />
                            <ext:ModelField Name="Birthdate" Type="Date" DateFormat="d/m/Y H:i:s">
                                <Convert Handler="return Ext.util.Format.date(value, 'd/m/Y H:i:s');" />
                            </ext:ModelField>
                        </Fields>
                    </ext:Model>
                </Model>
            </ext:Store>
        </Store>
        <ColumnModel ID="ColumnModel1" runat="server">
            <Columns>
                <ext:RowNumbererColumn ID="RowNumbererColumn1" runat="server" />
                <ext:Column ID="Column1" runat="server" Text="ID" DataIndex="ID" />
                <ext:Column ID="Column3" runat="server" Text="Name" DataIndex="Name" />
                <ext:Column ID="Column2" runat="server" Text="Birthdate" DataIndex="Birthdate" />
            </Columns>
        </ColumnModel>
    </ext:GridPanel>
    2 - Controller
    public class ExampleController : System.Web.Mvc.Controller
    {
        public ActionResult Index()
        {
            return View();
        }
    
        public StoreResult LoadFakeRecords()
        {
            List<Person> lst = new List<Person>();
    
            for (int index = 0; index < 15; index++)
            {
                lst.Add(new Person
                {
                    ID = index,
                    Name = "Name" + index,
                    Birthdate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, index)
                });
            }
    
            return new StoreResult(lst, lst.Count());
        }
    }
    3 - Utility
    public class Person
    {
        public int ID { get; set; }
    
        public string Name { get; set; }
    
        public DateTime Birthdate { get; set; }
    }
    Thanks in advance
    Last edited by Daniil; May 06, 2013 at 4:03 AM. Reason: [CLOSED]

Similar Threads

  1. Replies: 2
    Last Post: Dec 22, 2011, 2:45 PM
  2. [CLOSED] Time zone for time in UTC
    By krzak in forum 1.x Legacy Premium Help
    Replies: 11
    Last Post: Jun 01, 2011, 1:56 PM
  3. [CLOSED] Different time zone settings on DateFields
    By georgek in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 04, 2010, 1:40 AM
  4. [1.0] - JSON Serialize DateTime Request
    By drkoh in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 26, 2010, 1:56 PM
  5. [CLOSED] [1.0] Json Webservice DateTime Parsing Error
    By webclouder in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Jun 04, 2010, 1:10 AM

Posting Permissions