LS HTML Client, weird Date issue RRS feed

  • Question

  • Here's a strange one... In an application that I've just made, upon saving a record, LS seems to automatically modify the date of the record by exactly minus 1 day (say from 9/17 to 9/16). Now, there is some criteria for this to happen:

    1. An value must be modified that has not previously been modified in the record.  An example would be "Temperature", this is a required INT.  If I start a record and leave it at 0, Save, then go back into the record and add a value and Save, the date on the record is automatically changed back a day.

    Here's the kicker... the date change is only visual, the date value in the DB has not changed.  As soon as I hit F5 on my browser the date is correctly updated back to what was originally saved.

    The app does not have any events happening in the Updated/Updating/Inserting/Inserted methods.  The date is automatically added in the _Created event for the DB Entity.

    (this happens in both debug mode and when published to an Azure website).
    • Edited by billym99 Wednesday, September 17, 2014 7:30 PM
    Wednesday, September 17, 2014 7:29 PM

All replies

  • Hi,

    I noticed that this scenario occurs when you publish app to an Azure website.You’re building apps that are hosted in the cloud. Your users can be anywhere across the globe.

    This may caused by the different time zones.The client & server values will differ depending on location.

    Here's a detailed description of the new DateTimeOffset in LightSwitch 2013,please have a see:


    Best Regards,

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, September 19, 2014 6:11 AM
  • No, it doesn't have to do with publishing.  I've already included a function in the app to convert Azure's UTC time to EST.  Take a look at this video... the date issue occurs after a record has been saved.  Once it's modified the date is automatically changed back a day, although only visually.  A page refresh fixes it... the date change never actually occurs in the database. 

    This video should <hopefully> explain a little better:

    YouTube video of issue

    The interesting piece is that despite the date <visually> changing, it never actually changes in the database (at least when published).  I had SSMS open while editing a record and while dates will visually change on modified record a refresh of SSMS shows that the data in the DB has not been modified.  One other item... this DOES NOT occur in the Silverlight Desktop Client.

    • Edited by billym99 Saturday, September 20, 2014 12:28 AM
    Friday, September 19, 2014 7:42 PM
  • Billym99

    Where you able to get a fix for this problem?


    • Edited by cjh2os Tuesday, December 30, 2014 10:27 AM
    Monday, December 29, 2014 2:15 PM
  • submit issue
    Tuesday, December 30, 2014 1:24 AM
  • In our case, as we're based in the United Kingdom, this issue appears when British Summer Time is in effect but can be avoided by using DateTimeOffset fields rather than DateTime.

    Also, moving forward, the LightSwitch team have addressed this issue in the VS2015 version of the LightSwitch JavaScript library (msls-2.5.3).  The fix can also be applied in VS2013 by changing you can change the following section in the Scripts\msls-?.?.?.js file (i.e. in the initSaveChanges function moving the convertDatesToLocal call before the entityState check): -

    convertDatesToLocal(changeResponse.data); // MOVE TO HERE
    if (entityState === _EntityState.added) {
        //convertDatesToLocal(changeResponse.data); // MOVE FROM HERE

    Credit goes to Josh Booker for pointing out this change in the Town Hall thread.



    Saturday, February 14, 2015 1:39 PM
  • Hi!

    I've been having the exact same problem and unfortunately the workaround proposed above did not fix the issue or this workaround (from http://stackoverflow.com/questions/28483086/datetime-textbox-in-lightswitch-html-increments-one-hour-on-save/28491688#28491688)

    // Open msls-2.5.2.js
    // Locate this section of code:
    entitySet._loadedEntities[entityData.__metadata.uri] = entity;
                        } else if (entityState === _EntityState.modified) {
                            originalEntityData = entityData.__original;
                            $.each(entityDetails.properties.all(), function (j, property) {
    // You need to add: 
    // Example:
    entitySet._loadedEntities[entityData.__metadata.uri] = entity;
                            } else if (entityState === _EntityState.modified) {
                                originalEntityData = entityData.__original;
                                $.each(entityDetails.properties.all(), function (j, property) {
    // Hope this helps.

    One fortunate thing is that the change is only 'visual'.. so I'm okay with it for now although I would love to have a fix for this until I wait for VS 2015.



    Tuesday, April 7, 2015 6:30 PM