You can use the strftime method to format your time in any way. It uses a string as a parameter that determines the format of the output.
In fact, the iso8601 method uses strftime internally with "%FT%T"
as a format string.
To get the desired result, you can use this format string:
Time.now.getutc.strftime('%Y%m%dT%H%M%SZ')
, strftime
.