flash 用as2.0 获取系统时间

有时候我们需要利用FLASH获取系统的当前时间,其实简单的AS2命令就能满足我们的要求

 

function time() {
week = new Array("星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
date = new Date();
year = date.getFullYear();//按照本地时间返回年份数
month = date.getMonth()+1;//月
if(length(month)<2){//如果月份数字长度小余两位数
month = "0"+month;//月份的第一位数显示0
}
day = date.getDate();//天
if(length(day)<2){
day = "0"+day;
}
hour = date.getHours();//小时
if (length(hour)<2) {
hour = "0"+hour;
}
minute = date.getMinutes();//分钟
if (length(minute)<2) {
minute = "0"+minute;
}
second = date.getSeconds();//秒
if (length(second)<2) {
second = "0"+second;
}
week1 = date.getDay();//星期
mc.aa.text = year+"年"+month+"月"+day+"日 "+week[week1]//mc里面的动态文本AA内容
mc1.bb.text =hour+":"+minute+":"+second;//mc1动态文本的BB内容
}

你可能感兴趣的:(Date,function,Flash)