日期总是很重要(至少对我来说是如此),我面对的事实是Javascript似乎没有格式化日期的方法。
我正在尝试格式化日期以使用Google API,该格式要求您使用以下格式的日期:yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffff(例如2011-06-25T10:00:00.000 + 02:00)
我需要能够读取这种字符串并产生一个。
我经常使用jQuery插件:http://plugins.jquery.com/project/jquery-dateFormat
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="https://raw.github.com/phstc/jquery-dateFormat/master/jquery.dateFormat-1.0.js"></script>
<script type="text/javascript">
$(function() {
var d = new Date();
alert($.format.date(d, 'yyyy-MM-ddTHH:mm:ss'));
})
</script>