Time it's taking

This was super helpful. How could I create a displayed time of the difference counted from the beginning time until the current date/time? For example, if my start time were June 9th, I would want to see the time in days, minutes, and seconds until now. Thanks

a Date object can be used in mathematical operations, because it is represented as its timestamp (which is the number of seconds since the Unix Epoch, Midnight Jan 1 1970). So:

  • Get a Date for your target date;
  • Get the current Date (hint: an empty Date constructor will return the current Date by default.)
  • Subtract the larger from the smaller.
  • The result is the number of seconds between those two points in time.
  • Convert to whatever display you need.
2 Likes

Super helpful. I will use this to craft what I want. Thanks