Skip to content

Instantly share code, notes, and snippets.

@Klerith
Created November 2, 2022 20:36
Show Gist options
  • Save Klerith/f5cb31404fef4bad8160ce4eac5318b2 to your computer and use it in GitHub Desktop.
Save Klerith/f5cb31404fef4bad8160ce4eac5318b2 to your computer and use it in GitHub Desktop.
Fecha de creación humana
export const timeSince = ( date: string ) => {
const baseDate = new Date(date)
const seconds = Math.floor(( new Date().getTime() - baseDate.getTime() ) / 1000);
let interval = seconds / 31536000;
if (interval > 1) {
return Math.floor(interval) + " years";
}
interval = seconds / 2592000;
if (interval > 1) {
return Math.floor(interval) + " months";
}
interval = seconds / 86400;
if (interval > 1) {
return Math.floor(interval) + " days";
}
interval = seconds / 3600;
if (interval > 1) {
return Math.floor(interval) + " hours";
}
interval = seconds / 60;
if (interval > 1) {
return Math.floor(interval) + " minutes";
}
return Math.floor(seconds) + " seconds";
}
@backytadev
Copy link

Gracias profe!

@jcdelrioe
Copy link

Gracias!!!

@Ronstein
Copy link

Ronstein commented Aug 9, 2024

gracias profe

@jonatansegovia
Copy link

:)

@AgredaLuis
Copy link

Gracias!!

@hh2n
Copy link

hh2n commented Dec 30, 2024

Gracias!!

@IsaacC00
Copy link

Gracias profe!!!!

@LuFeSil
Copy link

LuFeSil commented Mar 10, 2025

🙏🙌✨🚀🔥💡👏😃

@fredy-glz
Copy link

Gracias!

@wcervera
Copy link

gracias profe!, excelente curso!

@junior-r
Copy link

Muchas gracias,! Muy buen curso

@tomiarg
Copy link

tomiarg commented Jul 28, 2025

Genio Fernando! eternamente agradecido por tus cursos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment