0

i have a json code that takes a specific date and i want it to be todays date. i looked and couldnt find any example: i would like to replace the last line below *date=2012-04-14 with today

<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=?**',
user1332985
  • 1
  • 1
  • 1
  • 3
  • You need to get current date in JS: http://stackoverflow.com/questions/1531093/how-to-get-current-date-in-javascript – adis Apr 14 '12 at 07:53

2 Answers2

1

To obtain the current date in Javascript simply instantiate a new date object

var currentDate = new Date();
glosrob
  • 6,631
  • 4
  • 43
  • 73
1
var now = new Date();
var strDate = now.getFullYear() + '-' + (now.getMonth()+1) + '-' + now.getDate();
Denys Séguret
  • 372,613
  • 87
  • 782
  • 758