Welcome aboard! We are happy you are here and wish you good net-raft!
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>
</head>
<body>
<div></div>
<script>
(function ($) {
$.fn.GetDaysAgo = function (day, month, year) {
var current_date = new Date();
var current_day = current_date.getUTCDate();
var current_month = current_date.getUTCMonth() + 1;
var current_year = current_date.getUTCFullYear();
// for days **********************************
myday = current_day - day;
if (myday == 0) {
days_ago = "created: Today";
}
if (myday == 1) {
days_ago = "created: " + myday + " day ago";
}
if (myday > 1 && myday <= 31) {
days_ago = "created: " + myday + " days ago";
}
// for months **********************************
mymonth = current_month - month;
if (mymonth == 1) {
days_ago = "created: " + mymonth + " month ago";
}
if (mymonth > 1) {
days_ago = "created: " + mymonth + " months ago";
}
// for years **********************************
myyear = current_year - year;
if (myyear == 1 ) {
days_ago = "created: " + myyear + " year ago";
}
if (myyear > 1 ) {
days_ago = "created: " + myyear + " years ago";
}
$(this).text(days_ago);
return this;
};
})(jQuery);
$(document).ready(function () {
var day = "20";
var month = "4";
var year = "2017";
$("div").GetDaysAgo(day,month,year);
});
</script>
</body>
</html>
The most helpful JQUERY solutions
plugin get client ip address using jqueryJQUERY Click to see more ... 10.9K 1.8K