时间戳转换日期格式 js JS时间格式转化?
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
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]
}
JS时间格式转换?
var d = new Date() d.setTime(1330912983320) var year = d.getFullYear() var month = d.getMonth() 1 var date = d.getDate() var hour = d.getHours() var minute = d.getMinutes() var second = d.getSeconds() alert(year "-" month "-" date " " hour ":" minute ":" second)你可以在判断下如果月日时小于10前边加个0
时间戳转换日期格式 js js日期格式转换yyyymmdd js字符串转日期格式
版权声明:本文内容由互联网用户自发贡献,本站不承担相关法律责任.如有侵权/违法内容,本站将立刻删除。