Mongodb Aggregation InvalidpipelineOperator Occurs Using Pipeline.

  mongodb, question

To build a log analysis system based on mongodb, the single document is as follows:

{
 "_id" : ObjectId("5c6a14c4421aa97a4714b291"),
 "some":"data"
 "startTime" : ISODate("2019-02-18T02:13:24.244Z"),
 "endTime" : ISODate("2019-02-18T02:13:24.279Z")
 }

Since startTime is a millisecond time, I made a group based on the second time, so I wrote the following code for conversion:

db.apiMonitor.aggregate([
 {
 $project:{
 groupField:'$startTime'
 }
 },{
 $project:{
 groupField:{
 $dateToString:{
 format:'%Y-%m-%d %H:%M:%S',
 date:'$groupField'
 }
 }
 }
 },{
 $project:{
 groupField:{
 $dateFromString:{
 format:'%Y-%m-%d %H:%M:%S',
 dateString:'$groupField'
 }
 }
 }
 }
 ])

The process is to convert ISODate into a time string through $dateToString to remove milliseconds of information, and then retransform ISODate through $ DATE FROMSRING, but the operation went wrong as follows:

command failed: {
 "ok" : 0,
 "errmsg" : "Unrecognized expression '$dateFromString'",
 "code" : 168,
 "codeName" : "InvalidPipelineOperator"
 }

Can you explain what caused this error, or is there any other solution?

Mongodb must have a version of 3.6 or more to use $dateFromString