JSFiddle - React, Tailwind, and code Playground

HTML

<input type='text' id='datepicker' value='Sun 1 Jan' />

<input type='button' id='getdate' value='What date is selected?' />

<input type='hidden' id='altdate' />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
<br />
    <br />
<br />
    <br />
<br />
    <br />
<p>
    Press the button, then change the date to the previous year, and press it again.
    <br />
    <br />
    The year is being discarded, and always returns the current year.
    <br />
    <br />
    This is a problem if you're only using the input for display purposes, and want to get the selected date in a machine-readable format programmatically.
    <br />
    <br />
    It's also inconsistent with what gets stored in altField.
</p>

JavaScript

$(document).ready(function() {
    $('#datepicker').datepicker({
        dateFormat: 'D dd M',
        altFormat: 'yy/mm/dd',
        altField: $('#altdate')
    });
    
    $('#getdate').click(function() {
       alert($('#datepicker').datepicker('getDate'));
       alert($('#altdate').val());
    });
})