我如何转换日期时间5/8/2011 12:00:00 AM
(m/d/yyyy) 到 dd-MMM-yyyy 类似08-May-2011
在 JavaScript 中。
这个链接是一个很好的资源,您可以使用。
http://blog.stevenlevithan.com/archives/date-time-format http://blog.stevenlevithan.com/archives/date-time-format
或者,您需要获取各个部分并根据需要将它们连接起来,如下所示。
var now = new Date();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
var monthnumber = now.getMonth();
var monthday = now.getDate();
var year = now.getYear();
String myOutput = monthday + "-" + monthnumer + "-" + year;
要获取月份名称而不是月份编号,您需要定义一个数组,如下所示
var arrMonths = new Array ("Jan","Feb"....};
String myOutput = monthday + "-" + arrMonths[monthnumer-1] + "-" + year;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)