[CLOSED] DateField timezone issues

  1. #1

    [CLOSED] DateField timezone issues

    We've just rolled out our Ext.NET app to India and find that when a date field is filled, the actual date posted is adjusted for the time-zone.
    e.g. 24th March 2001 ends up as Wed Mar 23 18:30:00 UTC 2011.

    I guess the DateField sends dates as UTC which is correct but I'm wondering is there an easy workaround to avoid the scenario I've just described? If a user anywhere in the world enters a DateField, I want that DateField to be consistent, so entering 24th March in the UK results in the same date being displayed in Asia, North America etc.

    As you can imagine, this causes serious problems for date of birth fields.
    Last edited by Daniil; Apr 01, 2011 at 12:40 PM. Reason: [CLOSED]
  2. #2
    I think I may have solved this myself by applying the value of the Date's getTimezoneOffset() method to the DateField's date value before posting, but I'm waiting on someone from from our Asia office to do some testing.

    Of course, any further suggestions until then are most welcome ;)
  3. #3
    Hi,

    You should be able to set the respective .Format for DateField.
    <ext:DateField runat="server" Width="200" XFormat="jS F Y" />
    I used .XFormat to set up a client side DateField's .format property as ExtJS date format string.
    http://dev.sencha.com/deploy/dev/docs/

    .Format expects C# data string format, then it's converted to ExtJS format string.
    http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

    But I'm not sure that it's possible to set up this format through .Format. Therefore I used .XFormat.
  4. #4
    Hi,

    I don't recommend to use XFormat otherwise DateField will not be able to parse submitted value
    Just set any required format (using Format property) and date will be submitted with that format
  5. #5
    Quote Originally Posted by Vladimir View Post
    I don't recommend to use XFormat otherwise DateField will not be able to parse submitted value
    Oh, I didn't think about it, thank you.
  6. #6
    Hmmm, I'm not sure I've explained the issue very well...

    To reduce to a simple case, I have a form panel, PersonForm, which contains a DateField to enter a date of birth and the form isn't posted but a button click event executes code to call a WCF service to save the form:

    var objUpdate = {};
    objUpdate.person = {};
    objUpdate.person.DateOfBirth = #{DateOfBirthField}.getValue();
    // assign other fields to objUpdate.person
    
    var param = Ext.util.JSON.encode(objUpdate);
    
    if (#{PersonForm}.isValid() {
        Ext.Ajax.request({
            url: '/Services/SavePerson.svc',
            method: 'POST',
            jsonData: param,
            success: function() {     Ext.Msg.alert('Done', 'Person saved'); }
            failure: function() {     Ext.Msg.alert('Failure', 'Save Person failed'); }
        });
    }
    else {     Ext.Msg.alert('Form validation failure', 'All mandatory fields must be filled'); }
    If I examine the request content after someone in India has entered a DateOfBirth of 24th March 2011, the date is encoded as "DateOfBirth":"/Date(1300905000000)/" which is seen as 23rd March 2011 18:30:00 on the server-side. I don't see how setting the format of the date field would help in this case, which is why I was suggesting that adjusting person.DateOfBirth before posting by adding the result of objUpdate.person.DateOfBirth.getTimezoneOffset() to objUpdate.person.DateOfBirth.

    Any comments or thoughts?
  7. #7
    It looks like a date is incorrectly encoded.

    We would suggest you to format it before encoding.

    objUpdate.person.DateOfBirth = #{DateOfBirthField}.getValue().dateFormat(here is required format)

Similar Threads

  1. [CLOSED] Wrong JSON Date Timezone ...
    By prointernet in forum 1.x Legacy Premium Help
    Replies: 17
    Last Post: May 22, 2014, 5:22 AM
  2. [CLOSED] MVC issues with getting ext.axd
    By craig2005 in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 06, 2012, 2:24 PM
  3. [CLOSED] IE9 Issues
    By pint in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Apr 19, 2011, 12:03 PM
  4. [CLOSED] IE9 issues
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 13
    Last Post: Mar 28, 2011, 7:06 PM
  5. Replies: 13
    Last Post: Sep 06, 2010, 7:51 PM

Posting Permissions