Sysdate on javascript

ลองเอาไปใช้กันน่ะครับ อิอิ

function getSysDate(elements){
var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
var curr_year = d.getFullYear();
var curr_hour = d.getHours();
var curr_minute = d.getMinutes();

curr_date = curr_date<10 ?"0"+curr_date:curr_date; curr_month = curr_month<10 ?"0"+curr_month:curr_month; curr_hour = curr_hour<10 ?"0"+curr_hour:curr_hour; curr_minute = curr_minute<10 ?"0"+curr_minute:curr_minute; var sys_date = curr_date + "/" + curr_month + "/" + curr_year+" "+ curr_hour+":"+curr_minute; elements.value = sys_date; }

ถ้าของใคร format ไม่เหมือนกับตัวอย่างก็ดัดแปลงกันตามที่ต้องการได้เลยครับ

Comments are closed.