我正在尝试显示 mysql 数据库中的日期值,它成功显示值,但显示日期“1970 年 1 月 17 日星期六 7:27 PM”
我正在使用以下代码
<script type="text/javascript">
$(document).ready(function () {
// prepare the data
var theme = 'energyblue';
var source =
{
datatype: "json",
datafields: [
{ name: 'startdate', type: 'date'},
{ name: 'scheduleend', type: 'date'},
{ name: 'venue', type: 'string'},
{ name: 'trainer', type: 'string'},
{ name: 'course', type: 'string'},
{ name: 'link', type: 'string'}
],
url: 'data.php',
cache: false,
filter: function()
{
// update the grid and send a request to the server.
$("#jqxgrid").jqxGrid('updatebounddata', 'filter');
},
sort: function()
{
// update the grid and send a request to the server.
$("#jqxgrid").jqxGrid('updatebounddata', 'sort');
},
root: 'Rows',
beforeprocessing: function(data)
{
if (data != null)
{
source.totalrecords = data[0].TotalRows;
}
}
};
var dataadapter = new $.jqx.dataAdapter(source, {
loadError: function(xhr, status, error)
{
alert(error);
}
}
);
// initialize jqxGrid
$("#jqxgrid").jqxGrid(
{
source: dataadapter,
theme: theme,
width: 1220,
filterable: true,
sortable: true,
autoheight: true,
pageable: true,
virtualmode: true,
localization: getLocalization('en'),
rendergridrows: function(obj)
{
return obj.data;
},
columns: [
{ text: 'Start Date', datafield: 'startdate', width: 260, cellsformat: 'f' },
{ text: 'End Date', datafield: 'scheduleend', width: 260, cellsformat: 'f'},
{ text: 'Venue', datafield: 'venue', width: 120 },
{ text: 'Trainer', datafield: 'trainer', width: 150 },
{ text: 'Course', datafield: 'course', width: 350 },
{ text: 'Link', datafield: 'link', width: 80, cellsalign: 'center', align: 'center', cellsformat: 'c2', cellsrenderer: function(row, cell, value) {
return '<div style="text-align: center; margin-top: 5px;"><a href="'+value+'"/>View</a></div>'
} }
]
});
});
</script>
为什么日期显示为“1970 年 1 月 17 日星期六 7:27 PM”?如何显示原始日期值?
任何参考或帮助将不胜感激。
问候