在js里面怎么把时间类型转换成字符串
1个回答
展开全部
在js里面怎么把时间类型转换成字符串
方法一:
var temper="2009-6-28 15:23"
var dt = new Date(temper.replace(/-/,"/"))
alert(dt)
方法二:
function ConvertDateFromString(dateString) {
if (dateString) {
var arr1 = dateString.split(" ");
var sdate = arr1[0].split('-');
var date = new Date(sdate[0], sdate[1], sdate[2]);
return date;
}
}
获得一个月中的总天数:
function GetDayInMonth(day) {
var today = day;
var year = today.getFullYear();
if (year < 2000) year += 1900; // Y2K fix
var month = today.getMonth();
var monarr = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
monarr[1] = 29;
return monarr[month];
}
方法一:
var temper="2009-6-28 15:23"
var dt = new Date(temper.replace(/-/,"/"))
alert(dt)
方法二:
function ConvertDateFromString(dateString) {
if (dateString) {
var arr1 = dateString.split(" ");
var sdate = arr1[0].split('-');
var date = new Date(sdate[0], sdate[1], sdate[2]);
return date;
}
}
获得一个月中的总天数:
function GetDayInMonth(day) {
var today = day;
var year = today.getFullYear();
if (year < 2000) year += 1900; // Y2K fix
var month = today.getMonth();
var monarr = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
monarr[1] = 29;
return monarr[month];
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询