2012-04-14 87 views
0

我有一個json代碼需要一個特定的日期,我希望它是今天的日期。我看了看,無法找到任何例子: 我想換成下面*日期的最後一行= 2012-04-14今天在json中插入今天的日期

<script src="http://code.jquery.com/jquery-latest.js"> </script> 
    <script type="text/javascript">// <![CDATA[ 
     $(document).ready(function() { 
      var inputField = $('#postnummer'); 
      var outputElement = $('#textResult'); 
      inputField.keyup(function() { 
      if (inputField.val().length > 3) { 
      $.getJSON('http://fraktguide.bring.no/fraktguide/products/SERVICEPAKKE/all.json?from=2862&to='+ inputField.val() +'&weightInGrams=2&**date=2012-04-14&callback=?**', 
+0

你需要獲得當前日期JS:http://stackoverflow.com/questions/1531093/how-to-get-current-date-in-javascript – adis 2012-04-14 07:53:31

回答

1

爲了獲得在Javascript當前日期是實例化一個新的日期對象

var currentDate = new Date(); 
1
var now = new Date(); 
var strDate = now.getFullYear() + '-' + (now.getMonth()+1) + '-' + now.getDate();