javascript:格式化日期
作者:admin 日期:2008-11-02
/*******************************************/
作者:mzoe
时间:2006-12-1 7:29:30
功能:格式化日期
调用说明:date_obj为时间对象,date_templet为返回的日期格式模版(如:date_obj为“2006-9-23 12:34:10”;date_templet为“yy年mm月”,返回:“06年9月”)
/*******************************************/
function getFormatDate(date_obj,date_templet){
var year,month,day,hour,minutes,seconds,short_year,full_month,full_day,full_day,full_hour,full_minutes,full_seconds;
if(!date_templet)date_templet = "yyyy-mm-dd hh:ii:ss";
year = date_obj.getFullYear().toString();
short_year = year.substring(2,4);
month = (date_obj.getMonth()+1).toString();
month.length == 1 ? full_month = "0"+month : full_month = month;
day = date_obj.getDate().toString();
day.length == 1 ? full_day = "0"+day : full_day = day;
hour = date_obj.getHours().toString();
hour.length == 1 ? full_hour = "0"+hour : full_hour = hour;
minutes = date_obj.getMinutes().toString();
minutes.length == 1 ? full_minutes = "0"+minutes : full_minutes = minutes;
seconds = date_obj.getSeconds().toString();
seconds.length == 1 ? full_seconds = "0"+seconds : full_seconds = seconds;
return date_templet.replace("yyyy",year).replace("mm",full_month).replace("dd",full_day).replace("yy",short_year).replace("m",month).replace("d",day).replace("hh",full_hour).replace("ii",full_minutes).replace("ss",full_seconds).replace("h",hour).replace("i",minutes).replace("s",seconds);
}
'引用自http://www.52515.net:8088/file.asp?fileid=3738322672713D323030372D322D3726626F61726469643D3431
作者:mzoe
时间:2006-12-1 7:29:30
功能:格式化日期
调用说明:date_obj为时间对象,date_templet为返回的日期格式模版(如:date_obj为“2006-9-23 12:34:10”;date_templet为“yy年mm月”,返回:“06年9月”)
/*******************************************/
function getFormatDate(date_obj,date_templet){
var year,month,day,hour,minutes,seconds,short_year,full_month,full_day,full_day,full_hour,full_minutes,full_seconds;
if(!date_templet)date_templet = "yyyy-mm-dd hh:ii:ss";
year = date_obj.getFullYear().toString();
short_year = year.substring(2,4);
month = (date_obj.getMonth()+1).toString();
month.length == 1 ? full_month = "0"+month : full_month = month;
day = date_obj.getDate().toString();
day.length == 1 ? full_day = "0"+day : full_day = day;
hour = date_obj.getHours().toString();
hour.length == 1 ? full_hour = "0"+hour : full_hour = hour;
minutes = date_obj.getMinutes().toString();
minutes.length == 1 ? full_minutes = "0"+minutes : full_minutes = minutes;
seconds = date_obj.getSeconds().toString();
seconds.length == 1 ? full_seconds = "0"+seconds : full_seconds = seconds;
return date_templet.replace("yyyy",year).replace("mm",full_month).replace("dd",full_day).replace("yy",short_year).replace("m",month).replace("d",day).replace("hh",full_hour).replace("ii",full_minutes).replace("ss",full_seconds).replace("h",hour).replace("i",minutes).replace("s",seconds);
}
'引用自http://www.52515.net:8088/file.asp?fileid=3738322672713D323030372D322D3726626F61726469643D3431
评论: 0 | 引用: 0 | 查看次数: 1545
发表评论
你没有权限发表留言!