我不熟悉javascript中的时间操作.
我尝试过new Date();以错误的格式给出结果:
2009年12月24日星期四14:24:06 GMT + 0800
如何获得格式的时间2009-12-24 14:20:57?
目前没有跨浏览器Date.format()方法.像Ext这样的工具包有一个但不是全部(我很确定jQuery没有).如果您需要灵活性,可以在网上找到几种此类方法.如果您希望始终使用相同的格式,那么:
var now = new Date();
var pretty = [
now.getFullYear(),
'-',
now.getMonth() + 1,
'-',
now.getDate(),
' ',
now.getHours(),
':',
now.getMinutes(),
':',
now.getSeconds()
].join('');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6447 次 |
| 最近记录: |