Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

155
Vistas
Showing Time duration using JQuery with Current Date time

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

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

const date = 'date that you have';
// Do your operations
const currentTime   = new Date();
const seconds = (currentTime.getTime() - date.getTime()) / 1000;

This will give you the seconds from the time you started til now. Now what you can do is that you can convert the seconds into minutes, hours or whatever you want.

Hope that this helped you solve your problem.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda