# Variable not defined

**URL:** <https://community.postman.com/t/variable-not-defined/9467>\
**Category:** Help Hub\
**Created:** [December 6, 2019, 1:38pm UTC](https://community.postman.com/t/variable-not-defined/9467 "2019-12-06T13:38:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![theToncheff](https://avatars.discourse-cdn.com/v4/letter/t/82dd89/32.png) [@theToncheff](https://community.postman.com/u/theToncheff)\
**Post date:** [December 6, 2019, 1:38pm UTC](https://community.postman.com/t/variable-not-defined/9467/1 "2019-12-06T13:38:30Z")

</div>

So I’m playing around with dates and I’m yet again encountering an issue that I’ve been trying to understand what causes it. As the title says, my issue is that I get an error that my variable is not defined:

```
var moment = require('moment');
pm.globals.set("timestampeeee", moment().toISOString());
console.log(timestampeeee)

```

So, the problem is that to my understanding is that it is defined as I can see it :

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/d/d347a9629ac8257fcdc5a55384b94d64ce21bb09.png)

So what am I missing, it seems so simple and yet…

---

<div class="post-metadata">

**Author:** ![arlem](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/arlem/32/3078_2.png) [@arlem](https://community.postman.com/u/arlem)\
**Post date:** [December 6, 2019, 2:57pm UTC](https://community.postman.com/t/variable-not-defined/9467/2 "2019-12-06T14:57:11Z")

</div>

I think the issue here is that you are not specifying from which scope the `timestampeee` variable must be pulled from when logging it out.  
If you’re writing it like this it implies that it is declared in the same Scripts sandbox (like `moment` for example) whereas you’ve assigned it to the global scope.

To print it out use `pm.globals.get("timestampeeee")` instead.

More information about variables and scopes can be found here:  
[https://learning.getpostman.com/docs/postman/environments-and-globals/variables/#variable-scopes](https://learning.getpostman.com/docs/postman/environments-and-globals/variables/#variable-scopes)
