Substract six hours DateTime retrieve data

2 posts, 0 answers
  1. Misahael
    Misahael avatar
    25 posts
    Member since:
    Oct 2013

    Posted 10 Mar 2014 Link to this post

    Hi,
    I have a problem when a data type DateTime is shown, the grid is automatically substracting six hours of the DateTime data.
    I use kendo.culture="es-EC" to avoid that, but still happening.

    In the localhost works fine.

    The system is host in Spain and the database too. The reports the grid export have the correct data, the problem seems only appear in the grid column. 

    Here's my code:

    <script src="@Url.Content("~/Scripts/kendo/2013.3.1324/cultures/kendo.culture.es-EC.min.js")"></script>
     
        <script>
            kendo.culture("es-EC");
    </script>

    My View:

    @(Html.Kendo().Grid(Model)
            .Name("Grid")
            .Columns(columns =>
            {
     
                columns.Bound(p => p.ID_SOLICITUDSERVICIO).Visible(false);
                columns.Bound(p => p.ID_PARTESERVICIO).Visible(false);
                columns.Bound(p => p.NOMBRE_EMPRESA).Title("Cliente");
                columns.Command(command => command.Custom("custom").Text("").Click("MostrarSolicitud")).Title("N°solicitud").Width(75);
                columns.Bound(p => p.SOLICITUD_CLIENTE).Title("ODT");
                columns.Bound(p => p.NOMBRE_ESTADOSOLICITUD).Title("Estado");
                columns.Bound(p => p.FECHA_INICIO).Format("{0: yyyy-MM-dd}").Title("Fecha inicio");
                columns.Bound(p => p.FECHA_FIN).Format("{0: yyyy-MM-dd}").Title("Fecha fin");
                columns.Bound(p => p.HORA_INICIO).Format("{0: HH:mm}").Title("Hora inicio");
                columns.Bound(p => p.HORA_FIN).Format("{0: HH:mm}").Title("Hora fin");
                columns.Bound(p => p.NOMBRE_TIPOSERVICIO).Title("Tipo servicio");
                columns.Bound(p => p.NOMBRE_MARCA).Title("Marca");
                columns.Bound(p => p.NOMBRE_MODELO).Title("Modelo");
                columns.Bound(p => p.SERIE_INVENTARIO).Title("N°serie");
                columns.Bound(p => p.DOCUMENTOS_PROCESADOS).Title("Doc. procesados")
                    .ClientFooterTemplate("# if (sum==null) { # Total: #= 0 # # } else { # Total: #=sum# # } #")
                    .ClientGroupFooterTemplate("# if (sum==null) { # #= 0 # # } else { # #=sum# # } #");
                columns.Bound(p => p.NOMBRE_UBICACION).Title("Loc./Proc. Equipo");
                columns.Bound(p => p.TECNICO_RESPONSABLE).Title("Técnico responsable");
                columns.Bound(p => p.NUMERO_TECNICOS).Title("N°técnicos");
                columns.Bound(p => p.TOTAL_HORAS).Title("Total de horas")
                    .ClientFooterTemplate("# if (sum==null) { # Total: #= 0 # h# } else { # Total: #=sum# h# } #")
                    .ClientGroupFooterTemplate("# if (sum==null) { # #= 0 # h# } else { # #=sum# h# } #");
                columns.Bound(p => p.FACTURA_PARTESERVICIO).Title("N°factura");
            })
                           .Sortable()
                           .Pageable(m => m.PageSizes(new int[] { 10, 20, 50, 100 }))
                           .Groupable()
                           .Filterable()
                           .Events(e => e.DataBound("dataBound"))
                           .Scrollable(s => s.Height("auto"))
                           .TableHtmlAttributes(new { style = "table-layout: fixed;" })
                           .Resizable(r => r.Columns(true))
                   .DataSource(dataSource => dataSource
                       .Ajax()
     
                                       .Aggregates(aggregates =>
                                       {
                                           aggregates.Add(m => m.DOCUMENTOS_PROCESADOS).Sum();
                                           aggregates.Add(m => m.TOTAL_HORAS).Sum();
                                       })
                               .Read(read => read.Action("LeerExt_MatrizServicios", "Consultas").Data("getParameter"))
                   )

    I attach some images that explain better the problem.

    Regards
  2. Daniel
    Admin
    Daniel avatar
    2231 posts

    Posted 12 Mar 2014 Link to this post

    Hello,

    The difference comes from the automatic browser conversion to local time when creating a new JavaScript date on the client. You should use UTC dates both on the client and on the server as demonstrated in this code library in order to avoid the conversion.

    Regards,
    Daniel
    Telerik
     

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

     
Back to Top