Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Postman Query Param to todays date?

Tags:

postman

I am trying to get the data from a period of time. They are set to actual dates but I wanted to know if it was possible to always have it set to today's date without having to go back and change it every time. query params

like image 515
Isaiah Bjorklund Avatar asked Oct 24 '25 15:10

Isaiah Bjorklund


1 Answers

You can add the following in the "Pre-request Script" heading below the URL field.

postman.setGlobalVariable('currentDate', (new Date()).toISOString());

Then add the variable wherever you are wanting to use the current date

{{currentDate}}

For example passing the current date as a query param

www.example.com/path?date={{currentDate}}
like image 143
Floppy52 Avatar answered Oct 27 '25 01:10

Floppy52



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!