﻿
function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}


function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function show_now()
{
    var timer_now = new Date();    
    var timer_year = timer_now.getYear();
    var timer_month = timer_now.getMonth()+1;
    var timer_day = timer_now.getDate();
    var timer_hour = timer_now.getHours();
    var timer_minute = timer_now.getMinutes();
    var timer_second = timer_now.getSeconds();
    var noon='';
    if(timer_hour>=12)
    {
        noon='下午';
        }else{
        noon='上午';
    }

    if("\v"!="v")
    {
        timer_year+=1900;
    }
aaa = document.getElementById('timeraaa');
aaa.innerHTML = '<font size=2>現在時間是 : '+timer_year + '/' + timer_month + '/' + timer_day + ' '+noon+' '+ Right( '00'+timer_hour,2) + ':'+Right( '00'+timer_minute,2) +':'+Right( '00'+ timer_second,2)+'<font size=2>';
         
         setTimeout('show_now()',1000);
 }
