js 时间操作和随机数操作

时间:2024-08-29 16:37:02
  function Data()
{
var date = new Date();
var year = date.getFullYear();
var month = date.getMonth() + ;
var strDate = date.getDate();
if (month >= && month <= ) {
month = "" + month;
}
if (strDate >= && strDate <= ) {
strDate = "" + strDate;
}
var newRandom = "";
for(var i=;i<;i++)
{
newRandom += Math.floor(Math.random()* + ).toString();
}
var currentdate = year + month + strDate + newRandom;
return currentdate;
}