1 Attachment(s)
[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.
Attachment 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
Code:
<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
Code:
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
Code:
public class Person
{
public int ID { get; set; }
public string Name { get; set; }
public DateTime Birthdate { get; set; }
}
Thanks in advance
Is there anything like this for Web Forms
Quote:
Originally Posted by
RCN
Sorry Vladimir, i thought it worked but it didn't. To accomplish it, it's necessary to do the following in the Global.asax:
Code:
Ext.Net.JSON.GlobalSettings.DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Local;
I tried this (web.config option) in my Web Forms site. I got an error stating that the attribute was unrecognized.