Appending date and time to output report (using newman-reporter-htmlextra)

Archived topic — this may be out of date.
Newman has been replaced by the Postman CLI, Postman’s official, signed command-line tool. It runs collections as Newman did, and also lints API specs, runs mocks and monitors, and syncs local files with Postman from your terminal, CI/CD pipeline or coding agent.
Working with an AI coding agent? The Postman plugin lets agents in Claude Code, Cursor, Codex and others design, mock, test and ship APIs with Postman.
For current help, see the Postman docs, try the free Postman tools (no account needed), or join us on Discord.

Hi,

I am wishing to produce an HTML report via Newman (newman-reporter-htmlextra), giving the output report a title of my choice, adding date and time to end of file name.

So at the moment, I am using -

–reporter-htmlextra-export path\path\path\test.html

which produces an HTML report called ‘test.html’.

I want to produce a report called ‘test_04022020_1202.html’ (for example).

How do I go about doing this?

Thanks!

It is not possible until you try to run collection from a cmd prompt.
It is possible if you run the collection programatically where you can add logic to get the current dateTime.
Refer: https://www.npmjs.com/package/newman-reporter-html#with-newman-as-a-library

Thanks for the fast response.

Yes, I am running from a cmd prompt. I was looking to see if there was a quick way of adding date and time to end of HTML report that is produced.

‘Running the collection programmatically’ is new for me. I guess I need to figure out a) how to run a collection programmatically, and b) how to include required logic into the program.

Unless, of course, there is a quicker way :slight_smile:

Hey @mrobbo85,

From the terminal, you can use date to help with this:

--reporter-htmlextra-export "test_$(date '+%d%m%Y_%H%M').html"

I’m not sure what the equivalent syntax would be for Windows, I think it might be the same :thinking:

Hi @danny-dainton ,

Cheers for this. On Windows, this just outputs a report with the title ‘test_$(date ‘+%d%m%Y_%H%M’).html’.

I’ll keep trying!

Thanks.

:cry:

I don’t have a windows machine but having a quick search around, it looks to be slightly trickier for windows, mainly due to the syntax.

I think it’s likely to be something like:

test_%DATE:~-4%%DATE:~4,2%%DATE:~7,2%_%TIME:~0,2%%TIME:~3,2%.html

You also still have the option of just removing that export flag and it will create the report, with the default name which includes the collection name plus a timestamp. That gets stored in the /newman directory.

:partying_face:

Nice one Danny! A sterling job considering you didn’t have a windows machine to hand. This worked for me =

test_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2%.html

Awesome! Glad I could help! :grin: