dimanche 7 novembre 2021

Simple way to display "years of service" in html/javascript

I am trying to display a number for years of service on a website. Essentially I thought I could put in a start date and current date to have an output of the years in between.

I can gt the current year using the following code but am unsure how to calculate the deference

<script>document.write(2010)+(/\d{4}/.exec(Date())[0])</script>



Aucun commentaire:

Enregistrer un commentaire