jQWidgets Forums

jQuery UI Widgets Forums Grid URGENT: The date field subtract one day automatically

This topic contains 18 replies, has 4 voices, and was last updated by  Peter Stoev 8 years, 11 months ago.

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author

  • SysProfile
    Participant

    Good day, this is part of a query I made to my database

    cmn_legajos_id cmn_lst_clientes_desc cmn_lst_clientes_un_desc           cmn_legajos_creacion
    428485	       Exiros	             SIDERAR S.A.I. y C.		2016-03-22
    428751	       Exiros	             Metalmecánica S.A.		        2016-03-23
    428890	       Exiros	             SIDERAR S.A.I. y C.		2016-03-28
    429224	       Exiros	             SIDERAR S.A.I. y C.		2016-03-31
    429229	       Exiros	             SIDERAR S.A.I. y C.		2016-03-31
    428994	       Exiros	             SIDERAR S.A.I. y C.		2016-03-29
    429161	       Exiros	             Scrap Services S.A.		2016-03-30

    This is part of the settings in jqxGrid

          var source = {
            localData: result,
            dataType: "json",
            dataFields: [
              {
                name: 'opr_lst_ftp_id',
                type: 'number'
              },
              {
                name: 'opr_obs_id',
                type: 'number'
              },
              {
                name: 'cmn_leg_ref_refclnt_pri_referencia',
                type: 'string'
              },
              {
                name: 'cmn_leg_ref_refclnt_sec_referencia',
                type: 'string'
              },
              {
                name: 'cmn_legajos_id',
                type: 'number'
              },
              {
                name: 'cmn_lst_clientes_desc',
                type: 'string'
              },
              {
                name: 'cmn_lst_clientes_un_desc',
                type: 'string'
              },
              {
                name: 'cmn_lst_clientes_dest_desc',
                type: 'string'
              },
              {
                name: 'cmn_legajos_creacion',
                type: 'date'
              },
              {
                name: 'cmn_lst_leg_estados_desc',
                type: 'string'
              },

          $("#datacontainer").jqxGrid({
            width: parseInt($("#datacontainer").css("width").replace("px", "")),
            height: parseInt($("#datacontainer").css("height").replace("px", "")),
            showgroupsheader: false,
            groupable: true,
            sortable: true,
            filterable: true,
            columnsResize: true,
            autoRowHeight: false,
            columnsReorder: true,
            columnsheight: 20,
            rowsheight: 20,
            autoShowLoadElement: false,
            filterMode: "excel",
            theme: "custom",
            localization: getLocalization(),
            source: dataAdapter,
            columns: [
              {
                text: "",
                cellsAlign: "center",
                align: "center",
                dataField: "opr_lst_ftp_id",
                filterable: false,
                sortable: false,
                menu: false,
                cellsrenderer: cellClip,
                renderer: function () {
                  return imgClip;
                }
              },
              {
              text: "",
              cellsAlign: "center",
              align: "center",
              dataField: "opr_obs_id",
              filterable: false,
              sortable: false,
              menu: false,
              cellsrenderer: cellPostIt,
              renderer: function () {
                return imgPostIt;
              }
              },
              {
                text: cmn_leg_ref_refclnt_pri_referencia,
                datafield: 'cmn_leg_ref_refclnt_pri_referencia',
                width: 130,
                cellsAlign: 'left',
                align: 'left'
              },
              {
                text: cmn_leg_ref_refclnt_sec_referencia,
                datafield: 'cmn_leg_ref_refclnt_sec_referencia',
                width: 130,
                cellsAlign: 'left',
                align: 'left'
              },
              {
                text: cmn_legajos_id,
                datafield: 'cmn_legajos_id',
                width: 70,
                cellsAlign: 'right',
                align: 'left'
              },
              {
                text: cmn_lst_clientes_desc,
                datafield: 'cmn_lst_clientes_desc',
                width: 220,
                cellsAlign: 'left',
                align: 'left'
              },
              {
                text: cmn_lst_clientes_un_desc,
                datafield: 'cmn_lst_clientes_un_desc',
                width: 220,
                cellsAlign: 'left',
                align: 'left'
              },
              {
                text: cmn_lst_clientes_dest_desc,
                datafield: 'cmn_lst_clientes_dest_desc',
                width: 140,
                cellsAlign: 'left',
                align: 'left'
    
              },
              {
                text: cmn_legajos_creacion,
                datafield: 'cmn_legajos_creacion',
                width: 90,
                cellsAlign: 'right',
                align: 'left',
                cellsFormat: 'dd/MM/yyyy'
              },

    var getLocalization = function () {
      var localizationobj = {};
      localizationobj.name = "es-AR";
      localizationobj.englishName = "Spanish (Argentine)";
      localizationobj.nativeName = "Español (Argentina)";
      localizationobj.language = "es";
      localizationobj.numberFormat = {
        ",": ".",
        ".": ",",
        "NaN": "No es un número",
        negativeInfinity: "-Infinito",
        positiveInfinity: "+Infinito",
        percent: {
          pattern: ["-n%", "n%"],
          ",": ".",
          ".": ","
        },
        currency: {
            pattern: ["-$ n", "$ n"],
            ",": ".",
            ".": ",",
            symbol: "$"
        }
      };
      localizationobj.calendars = {
          standard: {
            firstDay: 1,
            days: {
              names: ["domingo", "lunes", "martes", "miercoles", "jueves", "viernes", "sabado"],
              namesAbbr: ["dom", "lun", "mar", "mie", "jue", "vie", "sab"],
              namesShort: ["do", "lu", "ma", "mi", "ju", "vi", "sa"]
            },
            months: {
                names: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre", ""],
                namesAbbr: ["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic", ""]
            },
            AM: null, // ["AM", "am", "AM"]
            PM: null, // ["PM", "pm", "PM"]
            eras: [{ "nombre": "d.C.", "inicia": null, "diferencia": 0 }],
            twoDigitYearMax: 2029,
            patterns: {
              d: "M/d/yyyy",
              D: "dddd, MMMM dd, yyyy",
              t: "h:mm tt",
              T: "h:mm:ss tt",
              f: "dddd, MMMM dd, yyyy h:mm tt",
              F: "dddd, MMMM dd, yyyy h:mm:ss tt",
              M: "MMMM dd",
              Y: "yyyy MMMM",
              S: "yyyy\u0027-\u0027MM\u0027-\u0027dd\u0027T\u0027HH\u0027:\u0027mm\u0027:\u0027ss",
              ISO: "yyyy-MM-dd hh:mm:ss",
              ISO2: "yyyy-MM-dd HH:mm:ss",
              d1: "dd.MM.yyyy",
              d2: "dd-MM-yyyy",
              d3: "dd-MMMM-yyyy",
              d4: "dd-MM-yy",
              d5: "H:mm",
              d6: "HH:mm",
              d7: "HH:mm tt",
              d8: "dd/MMMM/yyyy",
              d9: "MMMM-dd",
              d10: "MM-dd",
              d11: "MM-dd-yyyy",
            }
          }
      };
      localizationobj.pagergotopagestring = "Ir a:";
      localizationobj.pagershowrowsstring = "Mostrar filas:";
      localizationobj.pagerrangestring = " de ";
      localizationobj.pagerpreviousbuttonstring = "previo";
      localizationobj.pagernextbuttonstring = "siguiente";
      localizationobj.groupsheaderstring = "Arrastre una columna y suéltela aquí para agrupar por esa columna";
      localizationobj.sortascendingstring = "Orden ascendente";
      localizationobj.sortdescendingstring = "Orden descendente";
      localizationobj.sortremovestring = "Eliminar orden";
      localizationobj.groupbystring = "Agrupar por esta columna";
      localizationobj.groupremovestring = "Eliminar del grupo";
      localizationobj.pagerfirstbuttonstring = "primero";
      localizationobj.pagerlastbuttonstring = "último";
      localizationobj.filterapplystring = "Aceptar";
      localizationobj.filtercancelstring = "Cancelar";
      localizationobj.filterclearstring = "Sin filtro";
      localizationobj.filterstring = "Filtrar";
      localizationobj.filtershowrowstring = "Mostrar filas:";
      localizationobj.filtershowrowdatestring = "Mostrar filas de fechas:";
      localizationobj.filterorconditionstring = "o";
      localizationobj.filterandconditionstring = "y";
      localizationobj.filterselectallstring = "(Seleccionar todo)";
      localizationobj.filterchoosestring = "Seleccione:";
      localizationobj.filtersearchstring = "Buscar:";
      localizationobj.filterstringcomparisonoperators = ['vacío', 'no vacío', 'contenga', 'contenga (sensitivo)',
         'no contenga', 'no contenga (sensitivo)', 'inicie con', 'inicie con (sensitivo)',
         'finalice', 'finalice (sensitivo)', 'igual', 'igual (sensitivo)', 'nulo', 'no nulo'];
      localizationobj.filternumericcomparisonoperators = ['igual', 'no igual a', 'menor que', 'menor que o igual a', 'mayor que', 'mayor que o igual a', 'nulo', 'no nulo'];
      localizationobj.filterdatecomparisonoperators = ['igual', 'no igual a', 'menor que', 'menor que o igual a', 'mayor que', 'mayor que o igual a', 'nulo', 'no nulo'];
      localizationobj.filterbooleancomparisonoperators = ['igual', 'no igual a'];
      localizationobj.validationstring = "El valor no es válido";
      localizationobj.emptydatastring = "No hay datos para mostrar";
      localizationobj.filterselectstring = "Seleccione el filtro";
      localizationobj.loadtext = "Cargando...";
      localizationobj.clearstring = "Limpiar";
      localizationobj.todaystring = "Hoy";
      return localizationobj;
    }

    The Result


    SysProfile
    Participant

    Image from Google Drive


    admin
    Keymaster

    Hi SysProfile,

    Most probably your DB and Local Host/Server are in different time zones.
    Set the format of:
    `{
    name: ‘cmn_legajos_creacion’,
    type: ‘date’,
    format: …..
    },
    `
    If necessary include the TZ info and apply it in your “format” property.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    SysProfile
    Participant

    Please could you tell me the string of characters including TZ

    Best Regards,
    Sergio Haurat


    SysProfile
    Participant

    I can confirm to you: The format and date/time are perfectly synchronized on my servers. Additionally, both are set to GMT-3

    Best Regards,
    Sergio Haurat


    Peter Stoev
    Keymaster

    Hi Sergio Haurat,

    As you say so. We don’t change the dates. We do: var date = new Date(your data string) and we display the result. So, difference may happen only because of different Time Zones.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    SysProfile
    Participant

    Dear Peter,
               I understand what you say, I bought the source code and see in jqxdate.js 4.1.1, written on line 193:
    { id: 'Argentina Standard Time', offset: -180, offsetHours: -3, displayName: '(UTC-03:00) Buenos Aires', supportsDaylightSavingTime: true },

    I figured that the error could be the supportsDaylightSavingTime variable: true, I changed to false and got the same result, always subtract 1 day. To understand the function does, I decided not specify a format in that column. This was the result:

    Actual value: 22/03/2016

    The return value is: Mon Mar 21 2016 21:00:00 GMT-0300 (Hora estándard de Argentina)

    The first question I ask myself is, where it gets the value 21:00:00?

    I checked my computer, the Web server (apache + php) and my server MariaDB. All computers are correctly synchronized, all computers GMT-3, same date and time.

    I reformatted the query using the date_format function ().

    If I use the format ‘% Y-% m-% d’, I get Sun April 3, 2016 21:00:00 GMT-0300
    If I use the format ‘% m-% d-% Y’, I get Tue Mar 29 2016 21:00:00 GMT-0300
    If I use the format ‘% d-% m-% Y’, I get Tue May 2018 21:00:00 GMT-03 0300

    Best Regards,
    Sergio Haurat


    SysProfile
    Participant

    This is json result

    [{"opr_lst_ftp_id":" ","opr_obs_id":"1","cmn_leg_ref_refclnt_pri_referencia":null,"cmn_leg_ref_refclnt_sec_referencia":"229900","cmn_legajos_id":"428485","cmn_lst_clientes_desc":"Exiros","cmn_lst_clientes_un_desc":"SIDERAR S.A.I. y C.","cmn_lst_clientes_dest_desc":null,"cmn_legajos_creacion":"2016-03-22","cmn_lst_leg_estados_desc":"SIM autorizado","opr_embarque_eta":"2016-04-01","opr_embarque_eta_dias":"-22","sim_lst_embalajes_desc":null,"opr_embarque_bultos":null,"opr_docrec_fac_dn":"82196, 82643, 82645, 82646, 82647, 82648, 82649, 82654, 82662, 82663, 82667, 82668","opr_docrec_fac_monto":"1683.10, 222.25, 888.00, 535.40, 738.00, 287.70, 2523.00, 497.38, 241.54, 402.57, 10350.00, 5132.00","opr_docrec_fac_condventa":"FCA","opr_lst_provcli_desc":"Houston Overseas Trading Co.","sim_lst_viamedio_desc":"A\u00e9reo","opr_docrec_doc_dn":"31102229","sim_caratula_destsimn":"16073SIMI064698K","sim_caratula_oficializacion":"2016-03-30","opr_djai_org_estado_BI15_fd":"2016-03-31","opr_djai_org_estado_BI15_fv":"2016-09-29","sim_caratula_estado":"SALI","opr_djai_org_estado_BI34_fb":"Si","opr_djai_org_estado_BI34_fd":"2016-04-14","opr_djai_org_estado_BI34_fv":"2016-10-11","opr_djai_org_estado_BI34_estado":"AUTO TOTAL","opr_djai_estado_fp":"2016-03-31","opr_djai_estado_fp_comprobante":"489164","opr_clasif_fgl":null,"opr_lst_obs_tipo_desc":"Impo Oper. - Otros \/ Observaciones, Impo Oper. - Intervenciones"},{"opr_lst_ftp_id":"428751","opr_obs_id":"1","cmn_leg_ref_refclnt_pri_referencia":null,"cmn_leg_ref_refclnt_sec_referencia":"181882","cmn_legajos_id":"428751","cmn_lst_clientes_desc":"Exiros","cmn_lst_clientes_un_desc":"Metalmec\u00e1nica S.A.","cmn_lst_clientes_dest_desc":null,"cmn_legajos_creacion":"2016-03-23","cmn_lst_leg_estados_desc":"Intervenida","opr_embarque_eta":"2016-04-01","opr_embarque_eta_dias":"-22","sim_lst_embalajes_desc":null,"opr_embarque_bultos":null,"opr_docrec_fac_dn":"0266129-IN","opr_docrec_fac_monto":"56.00","opr_docrec_fac_condventa":"FCA","opr_lst_provcli_desc":"Hallmark Sales Corporation","sim_lst_viamedio_desc":"A\u00e9reo","opr_docrec_doc_dn":null,"sim_caratula_destsimn":"16092SIMI065011Y","sim_caratula_oficializacion":"2016-04-01","opr_djai_org_estado_BI15_fd":"2016-04-02","opr_djai_org_estado_BI15_fv":"2016-09-28","sim_caratula_estado":"OBSR","opr_djai_org_estado_BI34_fb":"Si","opr_djai_org_estado_BI34_fd":"2016-04-03","opr_djai_org_estado_BI34_fv":"2016-09-30","opr_djai_org_estado_BI34_estado":"OBSERVADO","opr_djai_estado_fp":"2016-04-04","opr_djai_estado_fp_comprobante":"491647","opr_clasif_fgl":null,"opr_lst_obs_tipo_desc":"Impo Oper. - Auto de Impo, Impo Oper. - Intervenciones, Impo Oper. - Otros \/ Observaciones"},{"opr_lst_ftp_id":" ","opr_obs_id":"1","cmn_leg_ref_refclnt_pri_referencia":null,"cmn_leg_ref_refclnt_sec_referencia":"229902","cmn_legajos_id":"428890","cmn_lst_clientes_desc":"Exiros","cmn_lst_clientes_un_desc":"SIDERAR S.A.I. y C.","cmn_lst_clientes_dest_desc":null,"cmn_legajos_creacion":"2016-03-28","cmn_lst_leg_estados_desc":"SIM autorizado","opr_embarque_eta":"2016-04-01","opr_embarque_eta_dias":"-22","sim_lst_embalajes_desc":null,"opr_embarque_bultos":null,"opr_docrec_fac_dn":"MM 458279","opr_docrec_fac_monto":"15537.52","opr_docrec_fac_condventa":"FCA","opr_lst_provcli_desc":"Thermo Fisher Scientific","sim_lst_viamedio_desc":"A\u00e9reo","opr_docrec_doc_dn":"65405045","sim_caratula_destsimn":"16073SIMI071015Y","sim_caratula_oficializacion":"2016-04-07","opr_djai_org_estado_BI15_fd":"2016-04-08","opr_djai_org_estado_BI15_fv":"2016-10-07","sim_caratula_estado":"SALI","opr_djai_org_estado_BI34_fb":"Si","opr_djai_org_estado_BI34_fd":"2016-04-09","opr_djai_org_estado_BI34_fv":"2016-10-06","opr_djai_org_estado_BI34_estado":"OBSERVADO","opr_djai_estado_fp":"2016-04-07","opr_djai_estado_fp_comprobante":"496247","opr_clasif_fgl":null,"opr_lst_obs_tipo_desc":"Impo Oper. - Otros \/ Observaciones"},{"opr_lst_ftp_id":" ","opr_obs_id":"1","cmn_leg_ref_refclnt_pri_referencia":null,"cmn_leg_ref_refclnt_sec_referencia":"229932","cmn_legajos_id":"429224","cmn_lst_clientes_desc":"Exiros","cmn_lst_clientes_un_desc":"SIDERAR S.A.I. y C.","cmn_lst_clientes_dest_desc":null,"cmn_legajos_creacion":"2016-03-31","cmn_lst_leg_estados_desc":"Clasificada","opr_embarque_eta":"2016-04-01","opr_embarque_eta_dias":"-22","sim_lst_embalajes_desc":null,"opr_embarque_bultos":null,"opr_docrec_fac_dn":"140002995","opr_docrec_fac_monto":"4430.23","opr_docrec_fac_condventa":"FCA","opr_lst_provcli_desc":"KTB USA Import-Export LLC","sim_lst_viamedio_desc":"A\u00e9reo","opr_docrec_doc_dn":"39716494","sim_caratula_destsimn":"16073SIMI069713D","sim_caratula_oficializacion":"2016-04-06","opr_djai_org_estado_BI15_fd":"2016-04-09","opr_djai_org_estado_BI15_fv":"2016-10-06","sim_caratula_estado":"SALI","opr_djai_org_estado_BI34_fb":"Si","opr_djai_org_estado_BI34_fd":"2016-04-08","opr_djai_org_estado_BI34_fv":"2016-10-05","opr_djai_org_estado_BI34_estado":"OBSERVADO","opr_djai_estado_fp":"2016-04-06","opr_djai_estado_fp_comprobante":"494440","opr_clasif_fgl":null,"opr_lst_obs_tipo_desc":"Impo Oper. - Otros \/ Observaciones, Impo Oper. - Intervenciones"},{"opr_lst_ftp_id":" ","opr_obs_id":"1","cmn_leg_ref_refclnt_pri_referencia":null,"cmn_leg_ref_refclnt_sec_referencia":"229920","cmn_legajos_id":"429229","cmn_lst_clientes_desc":"Exiros","cmn_lst_clientes_un_desc":"SIDERAR S.A.I. y C.","cmn_lst_clientes_dest_desc":null,"cmn_legajos_creacion":"2016-03-31","cmn_lst_leg_estados_desc":"Clasificada","opr_embarque_eta":"2016-04-01","opr_embarque_eta_dias":"-22","sim_lst_embalajes_desc":null,"opr_embarque_bultos":null,"opr_docrec_fac_dn":"INV-2016.0056","opr_docrec_fac_monto":"536.00","opr_docrec_fac_condventa":"FCA","opr_lst_provcli_desc":"Tec-al Trade Gmbh","sim_lst_viamedio_desc":"A\u00e9reo","opr_docrec_doc_dn":"65106711","sim_caratula_destsimn":"16073SIMI069446G","sim_caratula_oficializacion":"2016-04-06","opr_djai_org_estado_BI15_fd":"2016-04-08","opr_djai_org_estado_BI15_fv":"2016-10-06","sim_caratula_estado":"SALI","opr_djai_org_estado_BI34_fb":"Si","opr_djai_org_estado_BI34_fd":"2016-04-08","opr_djai_org_estado_BI34_fv":"2016-10-05","opr_djai_org_estado_BI34_estado":"OBSERVADO","opr_djai_estado_fp":"2016-04-06","opr_djai_estado_fp_comprobante":"493963","opr_clasif_fgl":null,"opr_lst_obs_tipo_desc":"Impo Oper. - Otros \/ Observaciones"}]


    SysProfile
    Participant

    I found an example of the Grid component (http://jsfiddle.net/jqwidgets/5YtCm/) and I did work with json data in your code. The same problem occurs, always subtract 1 day. If you replace your part of html and javascript that designed by me (https://jsfiddle.net/SysProfile/65wx0zqr/) you can check the error.

    Please email me if you need any cooperation from me.


    SysProfile
    Participant

    SysProfile
    Participant

    Apache
    SetEnv TZ America/Argentina/Buenos_Aires

    PHP
    date.timezone = “America/Argentina/Buenos_Aires”

    MySQL
    default-time-zone = “America/Argentina/Buenos_Aires”


    taskmate
    Participant

    Hi

    I just ran your data on the fiddle example with json data and probably got correct results

    I found an example of the Grid component (http://jsfiddle.net/jqwidgets/5YtCm/) and I did work with json data in your code. The same problem occurs, always subtract 1 day. If you replace your part of html and javascript that designed by me (https://jsfiddle.net/SysProfile/65wx0zqr/) you can check the error.

    Kindly let me have some more details just in case I could be of any help

    Regards


    Peter Stoev
    Keymaster

    Hi SysProfile,

    jqxdate is not used in jqxGrid. I do not know why you looked at it. I would like to remind you that as per the EULA, you should not share our code or any portion of it. In your sample, you should set the format property of the datafield to match to your server date. I also wrote you that we do var date = new Date(your data string). Date is a Javascript Date Object, not jqxdate. It converts String to Local Date Time always. That is the reason you should set the format property of the data field to match your server’s date format and if possible include the TZ information when you return dates from your server. If you still don’t understand how to set the format property, look at: http://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxgrid/jquery-grid-datasources.htm?search= where you will find an example. Additional example with setting the format: https://jsfiddle.net/f46069j8/.

    Best Regards,
    Peter Stoev
    jQWidgets Team
    http://www.jqwidgets.com


    SysProfile
    Participant

    taskmate, Thanks for your reply. If you run this code (http://jsfiddle.net/SysProfile/5YtCm/137/) you read the date correctly?. The first record, column No. 2 (cmn_legajos_creacion). Real date, ‘2016-03-22’ and when I run the code, jsFiddle show me ‘Mon Mar 21 2016’


    SysProfile
    Participant

    Dear Peter, I now see that you are given in the definition of the input fields and the format of the column. In the examples there that I did not see it. As to what he tells me to expose code in principle I want to apologize. I thought it only showed “a record of a table” will not happen again. Please, if possible readdress to update the examples on the web and include these properties. Now I see it correctly. Thanks for your support

    Best Regards,
    Sergio Haurat

Viewing 15 posts - 1 through 15 (of 19 total)

The topic ‘URGENT: The date field subtract one day automatically’ is closed to new replies.