Code thời gian ngày giờ tháng năm chuẩn blogger blogspot
Nhatthienkt.net - Bộ code ngày giờ làm đẹp và thú vị hơn cho blog của bạn. Với blogger/blogspot thì các bạn sẽ gặp một số rắc rối về chuẩn code. Sau đây mình chia sẻ lại một số code làm thời gian thực theo thời gian hệ thống hiện thị giờ phút giây, ngày tháng năm cho blogspot.
1. Code mẫu 1 thời gian chèn trong theme
Mẫu:<script language="javascript" type="text/javascript">
dayName = new Array ("Chủ nhật","Thứ hai","Thứ ba","Thứ tư","Thứ năm","Thứ sáu","Thứ bảy")
monName = new Array ("1","2","3","4","5","6","7","8","9","10","11","12")
now = new Date
document.write("<font color=#FF6600><b>"+now.getHours()+ ":" +now.getMinutes()+ " phút - " +dayName[now.getDay()]+ ", " +now.getDate()+ "-" +monName[now.getMonth()]+ "-" +now.getFullYear()+ "</b></font>")
</script>
2. Mẫu 2:
Đang tải...
<center>
<div id="clock" class="smallfont" style="margin-left:5px;">Đang tải...</div>
<script type="text/javascript">
function refrClock()
{
var d=new Date();
var s=d.getSeconds();
var m=d.getMinutes();
var h=d.getHours();
var day=d.getDay();
var date=d.getDate();
var month=d.getMonth();
var year=d.getFullYear();
var days=new Array("Chủ nhật,","Thứ 2,","Thứ 3,","Thứ 4,","Thứ 5,","Thứ 6,","Thứ 7,");
var months=new Array("tháng 1,","tháng 2,","tháng 3,","tháng 4,","tháng 5,","tháng 6,","tháng 7,","tháng 8,","tháng 9,","tháng 10,","tháng 11,","tháng 12,");
var am_pm;
if (s<10) {s="0" + s}
if (m<10) {m="0" + m}
if (h>12) {h-=12;am_pm = "Chiều"}
else {am_pm="Sáng"}
if (h<10) {h="0" + h}
document.getElementById("clock").innerHTML=days[day] + " ngày " + date + " " + months[month] + " " + year + ", " + h + ":" + m + ":" + s + " " + am_pm;
setTimeout("refrClock()",1000);
}
refrClock();
</script>
</center>
Nhận xét
Đăng nhận xét