如果我有日期对象,如何在javascript中以2/25/2007格式显示日期
function formatDate(a) //pass date object
{
return (a.getMonth() + 1) + "/" + a.getDate() + "/" + a.getFullYear();
}
Run Code Online (Sandbox Code Playgroud)
这可行:
[date.getMonth() + 1, date.getDay(), date.getFullYear()].join('/')
Run Code Online (Sandbox Code Playgroud)