글쓴이:북극곰
이번에 좋아진 점이라면 출력형식에 html 태그를 넣을 수 있게 되었다는 것입니다.
< 와 > 사이에 있는 것들은 모두 변환하지 않도록 했거든요.
짝이 안맞으면 곤란하니깐 조심하시구요 ^^;
태그 바깥에서는 해당하는 영문자만 변환하므로 정확성도 높혔습니다.
// 날짜,시간 format 함수 = php의 date()
function date(arg_format, arg_date) {
if(!arg_date) arg_date = new Date();
var M = new Array(“Jan”,”Feb”,”Mar”,”Apr”,”May”,”Jun”,”Jul”,”Aug”,”Sep”,”Oct”,”Nov”,”Dec”);
var F = new Array(“January”,”February”,”March”,”April”,”May”,”June”,”July”,”August”,”September”,”October”,”November”,”December”);
var K = new Array(“일”,”월”,”화”,”수”,”목”,”금”,”토”);
var k = new Array(“日”,”月”,”火”,”水”,”木”,”金”,”土”);
var D = new Array(“Sun”,”Mon”,”Tue”,”Wed”,”Thu”,”Fri”,”Sat”);
var l = new Array(“Sunday”,”Monday”,”Tuesday”,”Wednesday”,”Thursday”,”Friday”,”Saturday”);
var o = new Array(“전”,”후”);
var O = new Array(“오전”,”오후”);
var a = new Array(“am”,”pm”);
var A = new Array(“AM”,”PM”);
var org_year = arg_date.getFullYear();
var org_month = arg_date.getMonth();
var org_date = arg_date.getDate();
var org_wday = arg_date.getDay();
var org_hour = arg_date.getHours();
var org_minute = arg_date.getMinutes();
var org_second = arg_date.getSeconds();
var hour = org_hour % 12; hour = (hour) ? hour : 12;
var ampm = Math.floor(org_hour / 12);
var value = new Array();
value[“Y”] = org_year;
value[“y”] = String(org_year).substr(2,2);
value[“m”] = String(org_month+1).replace(/^([0-9])$/,”0$1″);
value[“n”] = org_month+1;
value[“d”] = String(org_date).replace(/^([0-9])$/,”0$1″);
value[“j”] = org_date;
value[“w”] = org_wday;
value[“H”] = String(org_hour).replace(/^([0-9])$/,”0$1″);
value[“G”] = org_hour;
value[“h”] = String(hour).replace(/^([0-9])$/,”0$1″);
value[“g”] = hour;
value[“i”] = String(org_minute).replace(/^([0-9])$/,”0$1″);
value[“s”] = String(org_second).replace(/^([0-9])$/,”0$1″);
value[“t”] = (new Date(org_year, org_month+1, 1) – new Date(org_year, org_month, 1)) / 86400000;
value[“z”] = (new Date(org_year, org_month, org_date) – new Date(org_year, 0, 1)) / 86400000;
value[“L”] = ((new Date(org_year, 2, 1) – new Date(org_year, 1, 1)) / 86400000) – 28;
value[“M”] = M[org_month];
value[“F”] = F[org_month];
value[“K”] = K[org_wday];
value[“k”] = k[org_wday];
value[“D”] = D[org_wday];
value[“l”] = l[org_wday];
value[“o”] = o[ampm];
value[“O”] = O[ampm];
value[“a”] = a[ampm];
value[“A”] = A[ampm];
var str = “”;
var tag = 0;
for(i=0;i
switch(chr) {
case “<" : tag++; break;
case “>” : tag–; break;
}
if(tag || value[chr]==null) str += chr; else str += value[chr];
}
return str;
}