gpt4 book ai didi

javascript - 使用年、月、日、小时、秒格式每分钟刷新图像

转载 作者:行者123 更新时间:2023-11-28 07:34:00 26 4
gpt4 key购买 nike

<body>
<script language="javascript">

//Get Year, Month, Date, Hour and Minute to form Strings

var y = today.getFullYear();
var YY = y.toString();

var m = today.getMonth()+1;
if (m <= 9){
m = '0' + m;
}
var MM = m.toString();

var d = today.getDate();
if (d <= 9){
d = '0' +d;
}
var DD = d.toString();

var h = today.getHours();
if (h <= 9){
h = '0' + h;
}
var HH = h.toString();

var mi today.getMinutes();
if (mi <=9){
mi = '0' + mi;
}
var MiMi = mi.toString();

//Create image file in folder details, using year, month, date, hour and minute Strings
//Image file is in the /public_html folder, year+month+date sub-folder, hour sub-sub-folder,
// prefix with "tbmc_", year+month+date+hour+minutes in-between and ends with "59.jpg"
// Assgin folder and image file details to a variable F

var F = "/public_html/"+YY+MM+DD+"/"+HH+"/tbmc_"+YY+MM+DD+"_"+HH+MiMi+"59.jpg";

//Try to print but nothing happen


<img scr= "F" width="1" height="1">

</script>

</body>

最佳答案

您的 JavaScript 中有错误:我在开头添加了以下行:

var today = new Date();

并更正了该行:

    var mi = today.getMinutes();

其中缺少=。在这里 fiddle :http://jsfiddle.net/robbyn/g1ut9n08/

//Get Year, Month, Date, Hour and Minute to form Strings
var today = new Date();
var y = today.getFullYear();
var YY = y.toString();

var m = today.getMonth()+1;
if (m <= 9){
m = '0' + m;
}
var MM = m.toString();

var d = today.getDate();
if (d <= 9){
d = '0' +d;
}
var DD = d.toString();

var h = today.getHours();
if (h <= 9){
h = '0' + h;
}
var HH = h.toString();

var mi = today.getMinutes();
if (mi <=9){
mi = '0' + mi;
}
var MiMi = mi.toString();

//Create image file in folder details, using year, month, date, hour and minute Strings
//Image file is in the /public_html folder, year+month+date sub-folder, hour sub-sub-folder,
// prefix with "tbmc_", year+month+date+hour+minutes in-between and ends with "59.jpg"
// Assgin folder and image file details to a variable F

var F = "/public_html/"+YY+MM+DD+"/"+HH+"/tbmc_"+YY+MM+DD+"_"+HH+MiMi+"59.jpg";

//Try to print but nothing happen

alert(F);


//Get Year, Month, Date, Hour and Minute to form Strings
var today = new Date();
var y = today.getFullYear();
var YY = y.toString();

var m = today.getMonth()+1;
if (m <= 9){
m = '0' + m;
}
var MM = m.toString();

var d = today.getDate();
if (d <= 9){
d = '0' +d;
}
var DD = d.toString();

var h = today.getHours();
if (h <= 9){
h = '0' + h;
}
var HH = h.toString();

var mi = today.getMinutes();
if (mi <=9){
mi = '0' + mi;
}
var MiMi = mi.toString();

//Create image file in folder details, using year, month, date, hour and minute Strings
//Image file is in the /public_html folder, year+month+date sub-folder, hour sub-sub-folder,
// prefix with "tbmc_", year+month+date+hour+minutes in-between and ends with "59.jpg"
// Assgin folder and image file details to a variable F

var F = "/public_html/"+YY+MM+DD+"/"+HH+"/tbmc_"+YY+MM+DD+"_"+HH+MiMi+"59.jpg";

//Try to print but nothing happen

alert(F);

关于javascript - 使用年、月、日、小时、秒格式每分钟刷新图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28801596/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com