Here I have created sample that will help you out.
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script type="text/javascript">
$(function () {
$("#txtDate").datepicker({
maxDate: new Date()
});
$("#txtDate").change(function () {
$("#hfDate").val($("#txtDate").val());
});
});
function DateDiff() {
var datediff = prettyDate(new Date($('#txtDate').val()), new Date());
alert(datediff);
}
function prettyDate(date, now) {
var diff = (((now || (new Date())).getTime() - date.getTime()) / 1000),
day_diff = Math.floor(diff / 86400);
return day_diff == 0 && (
diff < 60 && "Just now" ||
diff < 120 && "1 minute ago" ||
diff < 3600 && Math.floor(diff / 60) + " minutes ago" ||
diff < 7200 && "1 hour ago" ||
diff < 86400 && Math.floor(diff / 3600) + " hours ago") ||
day_diff == 1 && "yesterday" ||
day_diff < 7 && day_diff + " days ago" ||
day_diff < 31 && Math.ceil(day_diff / 7) + " weeks ago";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
Select Date:
<input type="text" id="txtDate" value=" " />
<br />
<br />
<input type="button" value="Get Date Difference" onclick="DateDiff()" />
</div>
</form>
</body>
</html>
Demo