Two weeks have passed since I started my JavaScript Marathon along with writing this blog!
Time to celebrate.
Just yesterday, I worked with Dates in JavaScript.
So to celebrate this day, I created a universal function, which tells you the time that has passed from any moment in the past till the present moment.
Let’s go!
Here we go. Let’s create a function, which would take any Date as an argument and return us the information on how long ago it happened:
As an additional feature, I’d like to change the Date output into European format so it is presented as dd.mm.yy hh:mm:
Now, to check the result, let’s alert the following cases:
You may try it live at JSFiddle or by clicking “Results” below: