Having an updatedOn field

Can someone with a better understanding of Decap CMS tell me how would I add an updatedOn field that automatically updates?

I tried using the following code, but sometimes it works and sometimes it’s just empty:

CMS.registerEventListener({
  name: 'preSave',
  handler: ({ entry }) => {
    const updatedOn = entry.get('updatedOn');
    return entry.get('data').set('updatedOn', updatedOn);
  }
})

Netlify doesn’t provide support with Decap CMS.