编码:
function format_date( date, index )
{
if ( !date || ( index && !( date[ index ] ) ) )
{
return '';
}
console.log( date );
var date = new Date(
( index === undefined ) ? date : date[ index ]
);
console.log( date );
return ( date.getMonth() + 1 ) + '/' +
date.getDate() + '/' +
date.getFullYear() + ' 12:00 AM'
;
};
format_date( "2013-07-25" );
输出:
2013-07-25
Date {Wed Jul 24 2013 20:00:00 GMT-0400 (Eastern Standard Time)}
"7/24/2013 12:00 AM"
这是在 Linux 上运行的节点 JS 服务器上。的输出date
是:
Fri Aug 2 10:39:28 EDT 2013