Javascript中的日期格式化
做Java开发的人都知道,在Java中有XXXFormat(比如SimpleDateFormat)类可以帮助我们得到想要的数据格式.在JavaScript中没有这样的东西,所以我们需要用另一种方法得到我们想要的东西.代码如下:
<html>
<head>
<title>Test</title>
<mce:script type="text/javascript" language="javascript"><!--
function formatDate(now) {
var year = now.getYear();
var month = now.getMonth()+1;
var Date = now.getDate();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
return year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second;
}
var d = new Date(1230999938);
alert(formatDate(d));
// --></mce:script>
</head>
<body>
</body>
</html>
相关文档:
function MyObject1(formalParameter){
alert("MyObject1");
this.testNumber = formalParameter;
//1
this.toString= function(){
alert("MyObject1:"+this.testNumber);
&nbs ......
一、新增一个option
var sel=document.getElementById("select的id");
var op=document.createElement("option");
op.value=值;
op.text=显示文本;
sel.add(op);
二、删除一个option
var sel=document.getElementById("typelist");
if(sel.selectedIndex==-1)
alert("请选 ......
JavaScript的方法和技巧 收藏
有些时候你精通一门语言,但是会发现你其实整天在和其它语言打交道,也许你以为这些微不足道,不至于影响你的开发进度,但恰恰是这些你不重视的东西会浪费 你很多时间,我一直以为我早在几年前就已经精通JavaScript了,直到目前,我才越来越觉得JavaScript远比我想象的复杂和强大,我开始崇 ......
随着浏览器安全性的提高,要实现图片预览也越来越困难。
不过群众的智慧是无限的,网上也有很多变通或先进的方法来实现。
在研究了各种预览方法后,作为总结,写了这个程序,跟大家一起分享。
上次写的简便无刷新文件上传系统最初的目的就是用来实现这个图片预览效果。
兼容:ie6/7/8, firefox 3.5.5
后台支持下还兼容 ......