May 03, 2013, 12:21 PM
[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.
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
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 - Controllerpublic 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 - Utilitypublic 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]