How to get Google docs last edit date

前端 未结 3 1332
傲寒
傲寒 2021-02-20 10:24

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

相关标签:
3条回答
  • 2021-02-20 11:06

    The best way to go might be to go into the Tools menu and use the "Script editor". A little bit of code makes this not so difficult. Here's one example I found that seems to work.

    function onEdit(event) { var ss = event.source.getActiveSheet(); if (ss.getName() === 'Locations') { var dd = new Date(); ss.getRange(event.range.rowStart, 8).setValue(dd.toISOString()); } }

    In addition to the code you will need to accept some security dialog question, and you will need to setup a "trigger" for the project. These "triggers" are how you associate the code with an event in the Google Spreadsheet.

    Hope this helps.

    0 讨论(0)
  • 2021-02-20 11:09

    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.

    0 讨论(0)
  • 2021-02-20 11:09

    Use the Update method of the Files resource, enabling the 'setModifiedDate' boolean to true. This parameter will modify the timestamp of the file edition date, whenever the file has any type of modification.

    0 讨论(0)
提交回复
热议问题