Search code examples
postmanpostman-pre-request-scriptpostman-testcase

How to get current year in the Postman script


I have a requirement to get current year in the Postman pre-req script.

I'm planning to get the current date, then convert the date to string and apply sub-string to get year value

I would like to know, is this the right way of doing it, or is there any pre-defined function available to do it?


Solution

  • Another way to get current year :

    new Date().getFullYear();