Home > database >  How can I show the date in my database and not the current date with datetimepicker
How can I show the date in my database and not the current date with datetimepicker

Time:11-20

jQuery(document).ready(function () {
    if (jQuery("#HF_Date").length != 0) {
        console.log(jQuery("#HF_Date")[0].value)
        var valeurDate = jQuery("#HF_Date")[0].value == '' ? moment(new Date()).format("YYYY-MM-DD") : jQuery("#HF_Date")[0].value;
        jQuery('.TB_Date').datetimepicker({
            locale: 'fr',
            daysOfWeekDisabled: [0, 6],
            format: 'L',
            defaultDate: valeurDate
        });
    }
 });

<asp:TextBox ID="TB_Date" CssClass="TB_Date" Text='<%# Bind("Date") %>' runat="server"></asp:TextBox>
<asp:HiddenField runat="server" ID="HF_Date" Value='<%# Eval("Date") %>' />

My issue is when I want to modify it shows the current date instead of the date in my database

CodePudding user response:

your date format should be matched with picker's dateFormat.

$("#datepicker").datepicker({
  dateFormat: 'yy-mm-dd'
});

CodePudding user response:

jQuery('.TB_Date').datetimepicker('setDate', '<%# Bind("Date") %>');
  • Related