hyjw.net
当前位置:首页 >> js DAtE FormAt >>

js DAtE FormAt

function FormatDate (strTime) { var date = new Date(strTime); return date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate();}FormatDate("Tue Jul 16 01:07:00 CST 2013");

js中没有类似java中的DateFormat类来处理日期格式化,可以自己写一个: var newDate=new Date(); var year=newDate.getFullYear(); var month=(newDate.getMonth()+1)

Date.prototype.format = function(format) { var o = { "M+" : this.getMonth()+1, //month "d+" : this.getDate(), //day "h+" : this.getHours(), //hour "m+" : this.getMinutes(), //minute "s+" : this.getSeconds(), //second "q+" : Mat...

date转String: var now=new Date();var str=now.toString();String转date: var dt = new Date("2015/5/10 10:10:10");

js是不支持的 要想形成这样的格式,需要自己去拼写,可以参照以下js时间: var myDate = new Date(); myDate.getYear(); //获取当前年份(2位) myDate.getFullYear(); //获取完整的年份(4位,1970-????) myDate.getMonth(); //获取当前月份(0-11,0...

var now = new Date(); var year = now.getFullYear(); var month =(now.getMonth() + 1).toString(); var day = (now.getDate()).toString(); if (month.length == 1) { month = "0" + month; } if (day.length == 1) { day = "0" + day; } va...

无标题文档var SimpleDateFormat = function (pattern) { var reg = /[\-\/\.]/g; var format = new RegExp ("^[ymd]+" + reg.source + "[ymd]+" + reg.source + "[ymd]+$", "i"); if (!format.test (pattern)) { throw new Error ("the pattern...

方法一: 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('-')...

function add0(m){return m

function FormatDate (strTime) { var date = new Date(strTime); return date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate();}FormatDate("Tue Jul 16 01:07:00 CST 2013");

网站首页 | 网站地图
All rights reserved Powered by www.hyjw.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com