07-Jun-2021
.
Admin
Hii Guys,
In this example,I will learn you how to moment js humanize duration in laravel.you can easy and simply moment js humanize duration in laravel.
Here, i will give you simple example of jquery moment js fromNow() method provide you humanize duration.
Example :
<!DOCTYPE html>
<html>
<head>
<title>Moment JS Humanize Duration example - Nicesnippets.com</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js" crossorigin="anonymous"></script>
</head>
<body>
<h1> Moment JS Humanize Duration Example - Nicesnippets.com</h1>
</body>
<script type="text/javascript">
var monthAgo = moment().subtract(2, 'months').fromNow();
console.log(monthAgo);
var startDateTime = '05-06-2021'
var dayAgo = moment(startDateTime, "DD-MM-YYYY") .fromNow();
console.log(dayAgo);
</script>
</html>
Output :
2 months ago
3 days ago
It will help you...
#Jquery