jQWidgets Forums

jQuery UI Widgets Forums Editors DateTimeInput date from mysql not correct

Tagged: , ,

This topic contains 15 replies, has 3 voices, and was last updated by  Peter Stoev 12 years, 2 months ago.

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
  • date from mysql not correct #5752

    mr_putersmit
    Participant

    hello
    I stumbled across your set of widgets yesterday and from first impressions you have done a tremendous job in putting together a complete working package. I do have 1 question however. In MySql, the date format is in 0000-00-00. How do I display on screen dd/mm/yyyy? I have tried to find an answer but alas cannot. If someone could shed some light I would be grateful. Thanks

    date from mysql not correct #5755

    Peter Stoev
    Keymaster

    Hi mr_putersmit,

    To format dates, use the ‘formatString’ property of jqxDateTimeInput. This demo demonstrates how to format Dates: formatdate.htm.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    date from mysql not correct #5756

    mr_putersmit
    Participant

    hi P
    Thanks for reply. However, what I am trying to do is display a datetime field in then grid in the dd/mm/yyyy format. I have included a markup of what I am attempting to do, but obviously not working. Do I need to include the jqxdatetimeinput.js to display datetime field in the grid? Thanks

    $(document).ready(function () {
    // prepare the data
    var source =
    {
    datatype: "json",
    datafields: [
    { name: 'CompanyName'},
    { name: 'ContactName'},
    { name: 'ContactTitle'},
    { name: 'Address'},
    { name: 'City', type: 'date'},
    ],
    url: 'data.php'

    };

    var dataAdapter = new $.jqx.dataAdapter(source);

    $("#jqxgrid").jqxGrid(
    {
    source: source,
    theme: 'classic',
    width: 1200,
    altrows: true,
    enabletooltips: true,
    columns: [
    { text: 'Company Name', datafield: 'CompanyName', width: 250},
    { text: 'ContactName', datafield: 'ContactName', width: 150 },
    { text: 'Contact Title', datafield: 'ContactTitle', width: 180 },
    { text: 'Address', datafield: 'Address', width: 200 },
    { text: 'City', datafield: 'City', cellsformat: 'd', formatstring: "dd", width: 120
    }
    ]
    });
    });

    date from mysql not correct #5757

    Peter Stoev
    Keymaster

    Hi mr_putersmit,

    Well, with jqxGrid, the columns do not have such property. They have cellsformat which you have already set. If you have an issue with setting up a date, feel free to send your sample which demonstrates the issue to support@jqwidgets.com. May be the cellsformat should be set to ‘yyyy-MM-dd’.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    date from mysql not correct #5779

    mr_putersmit
    Participant

    Hi Peter

    It only seems to be happening to fields with a time entry. Entries with date display fine. I guess at entry level, what would be the correct markup to use to display a datetime field? Thanks

    date from mysql not correct #5788

    Peter Stoev
    Keymaster

    Hi mr_putersmit,

    Could you send us a small sample(if applicable) which illustrates the issue that you have with DateTime values formatting? We would like to test your specific scenario.

    In the mean time, you can customize DateTime cells rendering by manually formatting the values.

    For example:

                       { text: 'Date Début', dataField: 'Debut', width: 200, cellsformat: 'D',
    cellsrenderer: function (row, column, value) {
    var m = value.match(/^\/Date\((\d+)([-+]\d\d)(\d\d)\)\/$/);
    var date = null;
    if (m)
    date = new Date(1 * m[1] + 3600000 * m[2] + 60000 * m[3]);
    var dateString = $.jqx.dataFormat.formatdate(date, 'D');
    return '<div style="position: relative; margin-left: 4px; margin-top:4px;">' + dateString + '</div>';
    }
    },

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    date from mysql not correct #5792

    mr_putersmit
    Participant

    Peter

    I am getting error: value.match is not a function which relates to

    var m = value.match(/^\/Date\((\d+)([-+]\d\d)(\d\d)\)\/$/);

    in firebug. What exactly would you like me to send you? Thanks

    date from mysql not correct #5793

    Peter Stoev
    Keymaster

    A sample which demonstrates the issue that you report. You can send it to support@jqwidgets.com.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    date from mysql not correct #5826

    mr_putersmit
    Participant

    Peter

    I have spent some time researching this problem and can report there is definitely something strange happening. I can display dates correctly if they are AM. However, if they are PM they do not display correctly. 2 Questions, do I need some kind of country (UK) file? Reason I ask is because in the globalization folder, there are en-CA and en-US, no UK file?

    Secondly, is there a chart showing dependencies of what file needs other file to work?

    Thanks

    date from mysql not correct #5827

    Peter Stoev
    Keymaster

    Hi mr_putersmit,

    The download package comes with several built-in localization files. You can easily create new localization files, too.

    Here’s a sample file for German localization:

    (function($) {
    var cultures = $.global.cultures,
    en = cultures.en,
    standard = en.calendars.standard,
    culture = cultures["de-DE"] = $.extend(true, {}, en, {
    name: "de-DE",
    englishName: "German (Germany)",
    nativeName: "Deutsch (Deutschland)",
    language: "de",
    numberFormat: {
    ',': ".",
    '.': ",",
    percent: {
    pattern: ["-n%","n%"],
    ',': ".",
    '.': ","
    },
    currency: {
    pattern: ["-n $","n $"],
    ',': ".",
    '.': ",",
    symbol: "€"
    }
    },
    calendars: {
    standard: $.extend(true, {}, standard, {
    '/': ".",
    firstDay: 1,
    days: {
    names: ["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"],
    namesAbbr: ["So","Mo","Di","Mi","Do","Fr","Sa"],
    namesShort: ["So","Mo","Di","Mi","Do","Fr","Sa"]
    },
    months: {
    names: ["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember",""],
    namesAbbr: ["Jan","Feb","Mrz","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez",""]
    },
    AM: null,
    PM: null,
    eras: [{"name":"n. Chr.","start":null,"offset":0}],
    patterns: {
    d: "dd.MM.yyyy",
    D: "dddd, d. MMMM yyyy",
    t: "HH:mm",
    T: "HH:mm:ss",
    f: "dddd, d. MMMM yyyy HH:mm",
    F: "dddd, d. MMMM yyyy HH:mm:ss",
    M: "dd MMMM",
    Y: "MMMM yyyy"
    }
    })
    }
    }, cultures["de-DE"]);
    culture.calendar = culture.calendars.standard;
    })(jQuery);

    This demo shows how to apply localization: localization.htm.

    The dependencies are described in the “Getting Started” sections in the Online Documentation.

    I’ve asked you about a sample for the reported issues in my previous post. Would you send it to support@jqwidgets.com including the AM/PM issue that you report now? This will help us to better understand the issues in your scenario and also to provide better answers to your questions.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    date from mysql not correct #5828

    mr_putersmit
    Participant

    Peter

    I have sent snapshot of problem to the supplied email address. Thanks

    date from mysql not correct #5832

    Peter Stoev
    Keymaster

    Hi mr_putersmit,

    I am afraid that we haven’t received anything there. Could you double-check whether you sent the snapshot including the code to support@jqwidgets.com? If you are sending archives, rename them to .unzip, .unrar, etc.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    date from mysql not correct #5833

    mr_putersmit
    Participant

    Peter

    Nothing bounced back. I have resent now.

    Thanks

    date from mysql not correct #5915

    mr_putersmit
    Participant

    Peter

    Thanks for your help. Your suggestion in email worked fine. thanks

    date from mysql not correct #14575

    I have the same problem – AM/PM, can you help me?

    http://www.tuttiritratti.it/home/-mm/jpasto/cerca_test.php

    thanks

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

You must be logged in to reply to this topic.