How to get Google docs last edit date

Saurabh Sharma picture Saurabh Sharma · Dec 4, 2014 · Viewed 26.5k times · Source

I am working on an app in which I need to show the date when google doc was last edited.

Snapshot Here

I am able to get last modified date through Drive api

But it is different from last edited date for cases when file's metadata (e.g. permission) has changed and content hasn't.

Is there any way to get date when google doc was last edited?

Answer

Jordan Rhea picture Jordan Rhea · Apr 27, 2017

In Google Apps Script there is a DriveApp service that you can use. Something like this will work:

function lastUpdatedOn() {
  var FILE_ID = 'FILEID';

  return DriveApp.getFileById(FILE_ID).getLastUpdated();
}

The documentation for that is here: https://developers.google.com/apps-script/reference/drive/file#getlastupdated

Hope that helps.