相关疑难解决方法(0)

在JavaScript中获取当前日期和时间

我有一个脚本,用JavaScript打印当前的日期和时间,但DATE总是错的.这是代码:

var currentdate = new Date();
var datetime = "Last Sync: " + currentdate.getDay() + "/" + currentdate.getMonth() 
+ "/" + currentdate.getFullYear() + " @ " 
+ currentdate.getHours() + ":" 
+ currentdate.getMinutes() + ":" + currentdate.getSeconds();
Run Code Online (Sandbox Code Playgroud)

它应该打印18/04/2012 15:07:33和打印3/3/2012 15:07:33

有帮助吗?谢谢

javascript string time date concatenation

410
推荐指数
14
解决办法
103万
查看次数

标签 统计

concatenation ×1

date ×1

javascript ×1

string ×1

time ×1