jQueryMobile - DateBox

Home

jQuery Mobile Framework :: DateBox

A Date and Time Picker plugin for jQueryMobile

Conversion of Dates

Given the date 2001-03-04, lets convert it to Day, Month Date w/ Ordinal Suffix Year

Note that using this library *just* for this is a bit of a waste - maybe you want to look at DateBox-Unbound instead?

Convert

Converted date:

<div style="display: none">
    <input name="dbox" type="date" data-role="datebox" id="dbox" />
</div>
<p>Given the date 2001-03-04, lets convert it to Day, Month Date w/ Ordinal Suffix Year</p>
<a href="#" data-role="button" id="dodate">Convert</a>
<p>Converted date: <span id="outdate"></span></p>
$('#dodate').live('vclick', function() {
  // Set the input format
  $('#dbox').datebox({'overrideDateFormat': '%Y-%m-%d'});
  // Set the input date
  $('#dbox').val('2001-03-04').trigger('change');
  
  // callFormat with the output format and date
  $('#outdate').text($('#dbox').datebox('callFormat', '%A, %B %-d%o, %Y', $('#dbox').datebox('getTheDate')));
});