Reputation: 65
my jquery datepicker shows date correctly but the time isn't working. the test result produces the following: 1372046400 = 2013-06-24 04:06:00
as you can see the time isnt same as the systemtime, it should be 8:19pm.
<script type="text/javascript">
$(document).ready(function(){
$("#date").datepicker({
showButtonPanel: true,
minDate: '0M',
maxDate: '+90D',
dateFormat: "d-MM-yy",
onSelect : function(dateText, inst)
{ var epoch = $.datepicker.formatDate('@', $(this).datepicker('getDate')) / 1000;
$('#hidden1').val(epoch);
}
});
});
</script>
php script that displays the output
$dateTime = $_POST['hidden1'];
$date = new DateTime('@'.$dateTime);
echo $saveDate = $date->format('U = Y-m-d h:m:s');
Upvotes: 0
Views: 500
Reputation: 331
set your time zone (http://php.net/manual/en/function.date-default-timezone-set.php) and then try to use the answer that Sanath has suggested.
Example:-
date_default_timezone_set('America/Los_Angeles');
Upvotes: 2
Reputation: 4886
http://php.net/manual/en/function.date.php
it has to be
$date->format('U = "Y-m-d H:i:s');
m is for month
Upvotes: 4