我希望你能用一些JavaScript来帮助我,因为我有点迷失了......
我正在尝试以最简单的方式实现Date对象的下一格式字符串。
var now = new Date();
//how to convert to a pattern like this example: "30/1/2012 20:00:00" ?
提前致谢!
答案 0 :(得分:1)
使用以下链接中的format
功能,您可以执行以下操作:
var now = new Date();
now.format("dd/mm/yyyy hh:mm:ss");
答案 1 :(得分:1)
简单方法: http://jsfiddle.net/tftd/UtVnU/
var date = new Date();
//how to convert to a pattern like this example: "30/1/2012 20:00:00" ?
var time = date.getDay()+"/"+date.getMonth()+"/"+date.getYear()+" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
alert(time) /* Outputs 6/2/112 22:16:15 */
您可以从变量date
获取所有内容。