Tags

Now a days jQuery has become most popular in web base development. I’m new in jQuery and recently i faced problems converting jQuery datepicker’s date to timestamp as I’m storing date in database. PHP time() function generates 10 digits int number wheather jQuery generates 13 digits counting milliseconds. Thus I need to convert that. It’s not tough you can give a try.

$(function() {
var dates = $('#date').datepicker({
defaultDate: null,
changeMonth: true,
changeYear: true,
yearRange: '2000:2020',
dateFormat: 'dd-mm-yy',
numberOfMonths: 1,
onSelect : function(dateText, inst){
var epoch = $.datepicker.formatDate('@', $(this).datepicker('getDate')) / 1000;
$('#date').val(epoch);
}
});
});

Advertisements