Skip to content

isoTimestamp returns some random timestamp #4631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 of 5 tasks
rayrapetyan opened this issue May 9, 2025 · 6 comments · May be fixed by #4679
Open
3 of 5 tasks

isoTimestamp returns some random timestamp #4631

rayrapetyan opened this issue May 9, 2025 · 6 comments · May be fixed by #4679
Labels
bug Something isn't working

Comments

@rayrapetyan
Copy link

I have checked the following:

  • I have searched existing issues and found nothing related to my issue.

This bug is:

  • making Bruno unusable for me
  • slowing me down but I'm able to continue working
  • annoying
  • this feature was working in a previous version but is broken in the current release.

Bruno version

2.2.0

Operating System

Linux, Ubuntu 24

Describe the bug

Simply put {{$isoTimestamp}} as one of the request body parameters.

Expected: should be converted into current timestamp
Actual: some random timestamp from past or the future

.bru file to reproduce the bug

No response

Screenshots/Live demo link

Image

@rayrapetyan rayrapetyan added the bug Something isn't working label May 9, 2025
@fantpmas
Copy link

fantpmas commented May 9, 2025

Can confirm the same behaviour. Maybe the documentation is wrong and a random timestamp is meant?

@rayrapetyan
Copy link
Author

I don't think it's a documentation bug, postman uses the same variable: https://learning.postman.com/docs/tests-and-scripts/write-scripts/variables-list/. Also, there are 3 other variables ({{$randomDate*}}) for random timestamps.

@sww-jm
Copy link

sww-jm commented May 13, 2025

Same problem with normal timestamp. It also give back time in the future :-)

I need the unix time stamp for authorization against one of our api servers.

Image

@anusree-bruno
Copy link
Collaborator

Currently we are using random time to generate this

 timestamp: () => faker.date.anytime().getTime().toString(),
  isoTimestamp: () => faker.date.anytime().toISOString(),

see https://github.com/usebruno/bruno/blob/main/packages/bruno-common/src/utils/faker-functions.ts
will get this updated

@swobi71
Copy link

swobi71 commented May 14, 2025

@sww-jm
I use this little Pre Request script:

function getCurrentTimestamp() {
  return new Date().getTime();
}

bru.setVar("currentTimestamp", getCurrentTimestamp());

You then can use {{currentTimestamp}} in your requests.

If you add the following lines to the Pre Request script you can see the difference to {{$timestamp}} in the Developer Tools console:

bru.setVar("myTimestamp", "{{$timestamp}}");

console.log(bru.getVar("currentTimestamp"))
console.log(bru.getVar("myTimestamp")) 

@swobi71
Copy link

swobi71 commented May 15, 2025

ah, very nice! (and dividing by 1000 to get the timestamp in seconds totally makes sense)

maybe you could add a new variable "timestamp_ms" which contains the timestamp in milliseconds?
(this could be useful if consecutive requests in a fast succession need a unique timestamp)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
5 participants