也许是个老掉牙的问题,可实在没办法,正则就是学不会,败给他了。
nDate = new Date().toDateString();//显示为:Wed Aug 12 2009
可是想显示成'<span style="color:#009900">['+new Date().toDateString().substr(0,3)+'.]</span>'+new Date().toDateString().substr(3,4)+'.'+new Date().toDateString().substr(7)
笨办法:'<span style="color:#009900">['+nDate.substr(0,3)+'.]</span>'+nDate.substr(3,4)+'.'+nDate.substr(7)
正则是否简便些?
nDate = new Date().toDateString();//显示为:Wed Aug 12 2009
可是想显示成'<span style="color:#009900">['+new Date().toDateString().substr(0,3)+'.]</span>'+new Date().toDateString().substr(3,4)+'.'+new Date().toDateString().substr(7)
笨办法:'<span style="color:#009900">['+nDate.substr(0,3)+'.]</span>'+nDate.substr(3,4)+'.'+nDate.substr(7)
正则是否简便些?
解决方案 »
- 数组遍历的问题
- 多个iframe请求文件下载,为何只弹出一个下载框?
- 虚拟主机不支持虚拟目录,怎样把二级域名映射到子目录?
- ext-1.1.1 如何写一个默认关闭的面板
- ASP中如何改变TEXT文本框内输入字的字体和大小
- 求一个飘动图片代码!!
- 请教各位大侠,能否把下面这个脚本用javascript改写,多谢各位,我在线等待!!
- 想在当前页面中某个位置写一个字符串
- 怎样提交表单前判断文本框是否为空,给出提示信息
- 我有一个FRAME:Left和Right,想用JavaScript中OPEN方法,根据Left中参数的不同,打开不同的页面,定位到Right上(也就是不弹出新的页面
- 请教:字符串插入和修改颜色
- 急急急,在线急等!!!
nDate.GetMonth();//月
··························
L@_@K
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>js.date.prototypeExtesion.html</title>
<meta name="generator" content="editplus" />
<meta name="author" content="[email protected]" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head> <body>
<script type="text/javascript">
<!--
Date.prototype.getMonthAbbr = function() {
var monthAbbrs = ["Jan.", "Feb.", "Mar.", "Apr.", "May.", "Jun.", "Jul.", "Aug.", "Sept.", "Oct.", "Nov.", "Dec."];
return monthAbbrs[this.getMonth()];
};Date.prototype.getWeekDayAbbr = function() {
var weekDayAbbrs = ["Sun.", "Mon.", "Tue.", "Wed.", "Thu.", "Fri.", "Sat."];
return weekDayAbbrs[this.getDay()];
};document.write('<span style="color:#009900">['+new Date().toDateString().substr(0,3)+'.]</span>'+new Date().toDateString().substr(3,4)+'.'+new Date().toDateString().substr(7)+"<br />");var nDate = new Date();
document.write(nDate.getWeekDayAbbr(), " ", nDate.getMonthAbbr(), " ",nDate.getDate(), " ", nDate.getFullYear());
//-->
</script>
</body>
</html>
L@_@K
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>js.date.prototypeExtesion.html</title>
<meta name="generator" content="editplus" />
<meta name="author" content="[email protected]" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head> <body>
<script type="text/javascript">
<!--
Date.prototype.getMonthAbbr = function() {
var monthAbbrs = ["Jan.", "Feb.", "Mar.", "Apr.", "May.", "Jun.", "Jul.", "Aug.", "Sept.", "Oct.", "Nov.", "Dec."];
return monthAbbrs[this.getMonth()];
};Date.prototype.getWeekDayAbbr = function() {
var weekDayAbbrs = ["Sun.", "Mon.", "Tue.", "Wed.", "Thu.", "Fri.", "Sat."];
return weekDayAbbrs[this.getDay()];
};document.write('<span style="color:#009900">['+new Date().toDateString().substr(0,3)+'.]</span>'+new Date().toDateString().substr(3,4)+'.'+new Date().toDateString().substr(7)+"<br />");var nDate = new Date();
document.write(nDate.getWeekDayAbbr(), " ", nDate.getMonthAbbr(), " ",nDate.getDate(), " ", nDate.getFullYear());
//-->
</script>
</body>
</html>
L@_@K
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>js.date.prototypeExtesion.html</title>
<meta name="generator" content="editplus" />
<meta name="author" content="[email protected]" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head> <body>
<script type="text/javascript">
<!--
Date.prototype.getMonthAbbr = function() {
var monthAbbrs = ["Jan.", "Feb.", "Mar.", "Apr.", "May.", "Jun.", "Jul.", "Aug.", "Sept.", "Oct.", "Nov.", "Dec."];
return monthAbbrs[this.getMonth()];
};Date.prototype.getWeekDayAbbr = function() {
var weekDayAbbrs = ["Sun.", "Mon.", "Tue.", "Wed.", "Thu.", "Fri.", "Sat."];
return weekDayAbbrs[this.getDay()];
};document.write('<span style="color:#009900">['+new Date().toDateString().substr(0,3)+'.]</span>'+new Date().toDateString().substr(3,4)+'.'+new Date().toDateString().substr(7)+"<br />");var nDate = new Date();
document.write(nDate.getWeekDayAbbr(), " ", nDate.getMonthAbbr(), " ",nDate.getDate(), " ", nDate.getFullYear());
//-->
</script>
</body>
</html>