# Date Object Understanding

**URL:** <https://forum.freecodecamp.org/t/date-object-understanding/366510>\
**Category:** General\
**Created:** [April 1, 2020, 8:31am UTC](https://forum.freecodecamp.org/t/date-object-understanding/366510 "2020-04-01T08:31:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mizanmahi](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/mizanmahi/32/129621_2.png) [@mizanmahi](https://forum.freecodecamp.org/u/mizanmahi)\
**Post date:** [April 1, 2020, 8:31am UTC](https://forum.freecodecamp.org/t/date-object-understanding/366510/1 "2020-04-01T08:31:04Z")

</div>

```auto
const photoGallery = (title, dimensions, date) => {
    return {
      title,
      dimensions,
      date,
      info() {
        console.log(
          `Dimenstions of the photo ${this.title} are ${this.dimensions}`
        );
      },
      publishInfo: () => {
        console.log(
          `Foto was published ${Math.floor(
            (new Date().getTime() - date.getTime()) / 1000
          )} seconds ago`
        );
    }
  }
}
  
  const photo1 = photoGallery(
    "My dog",
    "1920x1080",
    new Date()
  );
  
 
  photo1.info();
  /* Dimenstions of the foto "My dog" are 1920x1080 */
  
  setTimeout(() => photo1.publishInfo(), 2000);
  /* Foto "My dog" was published 2 seconds ago */

```

Not understanding how setTimeout function is working here.  
If I call photo1.publishinfo() again in the console I get updated seconds, how?

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [June 1, 2021, 7:00pm UTC](https://forum.freecodecamp.org/t/date-object-understanding/366510/2 "2021-06-01T19:00:28Z")

</div>

Closed on June 1, 2021, 7:00pm UTC


