Я получаю формат даты в (Вт jul 05 2016 00:00:00 GMT+0530 (india standard time)) этот тип, но хочу, чтобы MM/dd/yyyy этот формат, как установить значения
<script> $(function () { $.ajax({ type: "GET", url: "/Test/GetMerchant" }).done(function (data) { //$("#leftMenu").hide(); var MyDateField = function (config) { jsGrid.Field.call(this, config); }; MyDateField.prototype = new jsGrid.Field({ sorter: function (date1, date2) { return new Date(date1) - new Date(date2); }, itemTemplate: function (value) { debugger if (value == "") return ""; else { var date = new Date(value).toDateString("MM/dd/yyyy") //return new Date(value).toDateString(); return value; } }, insertTemplate: function (value) { debugger var RDAte = value; //.toISOString("MM/dd/yyyy") var newdate = RDAte.toLocaleDateString('en-US') var d = new Date(newdate), month = '' + (d.getMonth() + 1), day = '' + d.getDate(), year = d.getFullYear(); if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day; var df = [month, day, year].join('/'); return this._insertPicker = $("<input>").datepicker({ defaultDate: new Date() }); }, editTemplate: function (value) { debugger var RDAte = value; //.toISOString("MM/dd/yyyy") var newdate = RDAte.toLocaleDateString('en-US') var d = new Date(newdate), month = '' + (d.getMonth() + 1), day = '' + d.getDate(), year = d.getFullYear(); if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day; var df = [month, day, year].join('/'); return this._editPicker = $("<input>").datepicker().datepicker("setDate", new Date(df)); }, insertValue: function () { debugger if (this._insertPicker.datepicker("getDate") != null) return this._insertPicker.datepicker("getDate"); //.toISOString("MM/dd/yyyy") else return this._insertPicker.datepicker("getDate"); }, editValue: function () { debugger if (this._editPicker.datepicker("getDate") != null) { //var RDAte = this._editPicker.datepicker("getDate"); //.toISOString("MM/dd/yyyy") //var newdate = RDAte.toLocaleDateString('en-US') //var d = new Date(newdate), //month = '' + (d.getMonth() + 1), //day = '' + d.getDate(), //year = d.getFullYear(); //if (month.length < 2) month = '0' + month; //if (day.length < 2) day = '0' + day; ////var df = [month, day, year].join('/'); //return [month, day, year].join('/'); return this._editPicker.datepicker("getDate"); } //return this._editPicker.datepicker("getDate").toISOString(); else //var RDAte = this._editPicker.datepicker("getDate"); //.toISOString("MM/dd/yyyy") //var newdate = RDAte.toLocaleDateString('en-US') //var d = new Date(newdate), //month = '' + (d.getMonth() + 1), //day = '' + d.getDate(), //year = d.getFullYear(); //if (month.length < 2) month = '0' + month; //if (day.length < 2) day = '0' + day; ////var df = [month, day, year].join('/'); //return [month, day, year].join('/'); //return this._editPicker = df; return this._editPicker.datepicker("getDate"); } }); jsGrid.fields.myDateField = MyDateField; $("#jsGrid").jsGrid({ height: "50%", width: "100%", filtering: true, editing: true, inserting: true, sorting: true, paging: true, autoload: true, pageSize: 12, pageButtonCount: 5, //pageLoading: true, deleteConfirm: "Do you really want to delete the merchandise?", controller: db, fields: [ { type: "control" }, { name: "Source", type: "text", width: 120, title: "Vendor" }, { name: "Description", type: "text", width: 210, validate: { message: "Description is required!", validator: function (value) { return value != ""; } } }, { name: "ModelNumber", type: "text", width: 120, title: "Model#/Item" }, { name: "SKU", type: "text", width: 90 }, { name: "SKU2", type: "text", width: 90 }, { name: "Comments", type: "text", width: 200 }, { name: "strReceiveDate", type: "myDateField", width: 80, align: "center", title: "Received" }, { name: "Location", type: "select", items: data.loc, valueField: "LocationID", textField: "Description", width: 100 }, { name: "Barcode", width: 80 }, { name: "BarcodePrinted", type: "checkbox", title: "Barcode Printed", sorting: false }, { name: "strLastUpdatedDate", type: "myDateField", width: 80, title: "Last Updated" }, { name: "DamageCode", type: "select", items: data.dam, valueField: "CodeID", textField: "CodeValue", title: "Damage" }, { name: "strCreatedDate", type: "myDateField", width: 80, title: "Created Date" }, { name: "strShipDate", type: "myDateField", myCustomProperty: "bar", width: 80, title: "Ship Date" }, { name: "strConsumeDate", type: "myDateField", myCustomProperty: "bar", width: 80, title: "Consume Date" }, { name: "PendingShipment", type: "checkbox", title: "Pending", sorting: false, width: 60 }, { name: "Donated", type: "checkbox", title: "Is Donated", sorting: false, width: 60 }, { name: "ReturnRequested", type: "checkbox", title: "Return Requested", sorting: false }, { name: "ReturnTo", type: "text", width: 150, title: "Return To" }, { name: "Quantity", type: "number", width: 50, title: "Qty" }, { name: "GroupName", type: "text", width: 150, title: "Group Name" }, { name: "CustomerID", width: 100, title: "Customer ID" }, ], }); }); }); </script>
Что я уже пробовал:
я пробую этот код, но не работаю
//var newdate = RDAte.toLocaleDateString('en-US')
//var d = новая дата(newdate),
//month = " + (d.getMonth() + 1),
//День = " + Д.функции getdate(),
//год = д getFullYear();
//если (месяц.длина < 2) месяц = '0' + месяц;
//if (day.length < 2) day = '0' + day;
//var df = [месяц, день, год].join('/');
//вернуть._editPicker = ДФ;
это мой полный код, и когда я редактирую #jsGrid, то дата сохраняется по умолчанию
("Thu Jun 09 2011 00:00:00 GMT+0530 (India Standard Time)") формат, но мне нужен 07/06/2016 этот формат