Q:

Can Someone Explain this regex snippet?

I found this replace code with what looks like regular expressions in them but I can't decipher the 
new Date().toISOString().
  replace(/[z|t|\.]/gim," ").
  replace(/\d{3}\s$/gim, " ").
  replace(/:\d{2}\s+$/, " ").
  trim() + "\n")

sorry if that's vague. I'm not really sure what I am looking at

A:

The code
new Date().toISOString()

generates something that looks like this
2015-07-01T17:21:22.123Z

The regex will put it into the format
2015-07-01 17:21

All of the regex has the flags g, m, and i. Straight from regex101 this means:

g modifier: global. All matches (don't return on first match)
i modifier: insensitive. Case insensitive match (ignores case of [a-zA-Z])
m modifier: multi-line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)

The first regex
[z|t|\.]

actually already has a mistake. Whoever wrote it assumed that | means or but this is not the case inside the square brackets. It could be better written as
[zt\.]

This will match 2015-07-01T17:21:22.123Z and then the replace
replace(/[z|t|\.]/gim," ")

will replace every character that matches that regex with a space. Giving you the new string
2015-07-01 17:21:22 123

The next regex \d{3}\s$ matches and replaces 2015-07-01 17:21:22 123 , giving you:
2015-07-01 17:21:22

Finally the regex :\d{2}\s+$ matches and replaces  2015-07-01 17:21:22 , giving you
2015-07-01 17:21

And then the extra spaces are trimmed off.
All in all this is not that great of a way to do what you want. You could probably either do it better with substrings or with momentjs as someone else already said.

