In my web application, I show the user the request posted date time in the view.
I want to additionally show how long ago that was posted with Date time now.
What is the easiest way to show it
This is the Code
<div class="timeline">
<div class="time-label">
<span class="bg-green">
<label id="dateRequested">@Model.First().Approved_Date</label>
</span>
</div>
<div>
<i class="fas fa-envelope bg-blue"></i>
<div class="timeline-item">
<span class="time">
<i class="fas fa-clock"></i>
</span>
</div>
<i class="fas fa-user bg-green"></i>
<div class="timeline-item">
<span class="time">
<i class="fas fa-clock"></i> 5 mins ago </span>
<h3 class="timeline-header no-border">
<a href="#">Managers</a> Previously Approved By
</h3>
</div>
</div>
</div>
<script type="text/javascript">
const date = $('#dateRequested');
console.log(date);
// Do your operations
const currentTime = new Date();
console.log(currentTime);
const seconds = (currentTime.getTime() - date.getTime()) / 1000;
console.log(seconds);
</script>
@Model.First().Approved_Date
(this shows as (12/23/2021 12:10:11 PM)) here shows the posted date and I want to get the difference between that date with Date time now and show the difference in the 5 mins ago
place. Can I get help to create this? Thanks