java:
SimpleDateFormat simple = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss" , Locale.CHINA);
System.out.println (simple.format(new Date()));
Javascript:
<script >
var s ="-";
var t = ":";
var today = new Date();
mon = today.getMonth();
day =today.getDay();
hrs=today.getHours();
min=today.getMinutes();
sec=today.getSeconds();
mon = (mon<10?"0":"")+mon;
day = (day<10?"0":"")+day;
clckh=""+((hrs>12)?hrs-12:hrs);
clckm=((min<10)?"0":"")+min;
clcks=((sec<10)?"0":"")+sec;
var show = today.getYear()+s+mon+s+day+" "+clckh+t+clckm+t+clcks;
alert (show);
</script>
本文地址:http://com.8s8s.com/it/it25634.htm