# Some questions about millis()

**URL:** <https://discourse.processing.org/t/some-questions-about-millis/19541>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [April 8, 2020, 2:17pm UTC](https://discourse.processing.org/t/some-questions-about-millis/19541 "2020-04-08T14:17:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![NKF](https://avatars.discourse-cdn.com/v4/letter/n/b9e5f3/32.png) [@NKF](https://discourse.processing.org/u/NKF)\
**Post date:** [April 8, 2020, 2:17pm UTC](https://discourse.processing.org/t/some-questions-about-millis/19541/1 "2020-04-08T14:17:41Z")

</div>

I know millis() is the number of milliseconds since starting the program, but how can I reset millis() to 0 in order to re-counting the time?

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 8, 2020, 4:06pm UTC](https://discourse.processing.org/t/some-questions-about-millis/19541/2 "2020-04-08T16:06:32Z")

</div>

That’s not how it works.

Instead make a new variable timer or startTime and set it to millis(); (when you want to set millis to 0)

Then millis() - startTime gives you the amount of millis you are looking for

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 8, 2020, 8:11pm UTC](https://discourse.processing.org/t/some-questions-about-millis/19541/3 "2020-04-08T20:11:48Z")

</div>

Hello,

You can’t reset millis().  
You can start a time elapsed counter that counts from the time started.

A simple example:

```auto
int timeStart;
int timeElapsed;

void setup() 
  {
  timeStart = millis();
  }

void draw() 
  {
  timeElapsed = millis() - timeStart;
  println(timeElapsed);
  }

void keyPressed()
  {
  timeStart = millis(); //Resets time elapsed counter
  }

```

`:)`

Other millis() examples here:

> **[25 life-saving tips for Processing](https://amnonp5.wordpress.com/2012/01/28/25-life-saving-tips-for-processing/)**
>
> I have bundled a huge number and variety of code examples in this single mega-post. Please learn from my mistakes and experiences! ;-)

---

<div class="post-metadata">

**Author:** ![NKF](https://avatars.discourse-cdn.com/v4/letter/n/b9e5f3/32.png) [@NKF](https://discourse.processing.org/u/NKF)\
**Post date:** [April 9, 2020, 6:12am UTC](https://discourse.processing.org/t/some-questions-about-millis/19541/4 "2020-04-09T06:12:41Z")

</div>

glv, Thank you so much!! I got it now

---

<div class="post-metadata">

**Author:** ![NKF](https://avatars.discourse-cdn.com/v4/letter/n/b9e5f3/32.png) [@NKF](https://discourse.processing.org/u/NKF)\
**Post date:** [April 9, 2020, 6:13am UTC](https://discourse.processing.org/t/some-questions-about-millis/19541/5 "2020-04-09T06:13:31Z")

</div>

Chrisir, Thank you for your help!!
