Make the code more concise with jQuery :
(1) Add this to your <head>:
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
(2) Create the element in which you want to display the variable and specify an identifier for it, for example:
<span id="printHere"></span>
(3) Add this to your JavaScript:
var duration="<?php echo $postduration ?>";
$('#printHere').html(duration);
For your PHP, try the following two options:
<?=$postduration?>
or...
<?php echo $postduration; ?>
source
share