1

I need to send variables using get method, but the date format should be "dd-monthName-YYYY" just like "02-February-2015" for example.

Can it be done using HTML5 type="date"?

If it can't, then how can i do that?

stormrage
  • 231
  • 1
  • 3
  • 17
  • Dropdown of HTML5 date, is self explanatory. Still if you want to get month name then you could use jQuery Datepicker, visit: http://jqueryui.com/datepicker/#default – Gaurav Dave Feb 02 '15 at 05:46

1 Answers1

-1

You can do it so:

<html>
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<body>

    <input id="datefield" type="date" />

    <script>
        var monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ];

        $("#datefield").change(function () {
            var val = $(this).val();
            console.log(val);
            var d = new Date(val);
            console.log(d.getDate() + '-' + monthNames[d.getMonth()] + '-' + d.getFullYear());
        });
    </script>

</html>

Result:

2015-02-02
2-February-2015
Rob
  • 26,989
  • 16
  • 82
  • 98
Alex Vazhev
  • 1,363
  • 1
  • 18
  • 17