I would like to know how I can change the date in my “selectedDate” with jquery datepick. Here’s my HTML where I want the magic to show
<h3>Historique des tâches (<span class="selectedDate"><?= date("Y-m-d");?></span>) <span class="chooseDate">Choisir date</span> <span class="taskDate"></span></h3>
And the javascript
$(".chooseDate").toggle(function() {
$(this).text("Choisir date");
$(".taskDate").datepick({
onSelect: function(date) {
alert($.datepick.formatDate(date))
}
});
},
function() {
$(this).text("Choisir date");
$(".taskDate").datepick('destroy');
});
When I select a date it should popup an alert message with the selected date in yyyy-mm-dd format but nothing happens.
Could someone help me?
Thanks
Update (Found it):
$(".taskDate").datepick({
onSelect: function(test){
var newDate = new Date(test);
alert(newDate.getFullYear()+'-'+(newDate.getMonth()+1)+'-'+newDate.getDate());
}
});
I’ve just reformat the date it gave me to the one I wanted. Event by telling it the show it in yyyy-mm-dd format it was still showing me the full date with day , time zone, etc…
Thanks guys
Try this
OK, then try this: