Question

I use the Datepicker from https://github.com/arschmitz/jquery-mobile-datepicker-wrapper for jQuery Mobile.

<label for="nachname">Geburtsdatum</label>
<input type="text" id="datepicker" data-role="date" name="gebdat">

with

<script language="javascript" type="text/javascript">
    $(function() {
        $('#datepicker').date({ dateFormat: 'yy-mm-dd' }).val()
    });
</script>

but the format is still 04/16/2014.

Can you help me please?

Was it helpful?

Solution 2

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!--jQuery-->
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<!--jQuery UI-->
<script src="http://view.jqueryui.com/master/ui/datepicker.js"></script>
<!--jQuery Mobil--> 
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css">  
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
<!-- jQuery Mobile Datepicker -->
<link href="http://rawgithub.com/arschmitz/jquery-mobile-datepicker-wrapper/master/jquery.mobile.datepicker.css" rel="stylesheet">
<script src="http://rawgithub.com/arschmitz/jquery-mobile-datepicker-wrapper/master/jquery.mobile.datepicker.js"></script>
</head>

<body>

<div data-role="page" id="pageone">
<div data-role="header">
<h1>Start</h1>
</div>

<div data-role="main" class="ui-content"> 
<form action="this.php" method="post" data-ajax="true">
<label for="gebdat">Date</label>
<input type="text" name="gebdat" data-role="date" data-date-format="yy-mm-dd" >

<button type="submit" name="submit" class="ui-btn-hidden" data-icon="edit" aria-disabled="false">Save</button>

</form>
 </div>

  <div data-role="footer">
    <h1>End</h1>
  </div>
</div> 

</body>

</html>

With data-date-format="yy-mm-dd" you set the format and not with jQuery.

OTHER TIPS

This is how I solved mine. The page says its an extension of jquery ui base, so bascially I followed how jquery ui sets its format.

$( "#startDate" ).datepicker({"dateFormat": "yy/mm/dd"});

Hope this helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top