You can retrieve the shared date using Drive API v2. "Drive API v2" can be used at Google Apps Script by enabling Drive API of Advanced Google services and of Google API Console.
How to use it is as follows.
In the script editor, select Resources > Advanced Google services
In the dialog that appears, click the on/off switch for Drive API v2.
At the bottom of the dialog, click the link for the Google API Console.
In the console, click into the filter box and type part of the name of the API "Drive API", then click the name once you see it.
On the next screen, click Enable API.
Close the Developers Console and return to the script editor. Click OK in the dialog. The advanced service you enabled is now available in autocomplete.
The detail information is https://developers.google.com/apps-script/guides/services/advanced.
At the sample script, it searches "sharedWithMe" using q
and displays file ID, file name, shared date and share using fields
. They are displayed by JSON. If the response is no data, it indicates there are no sharedwithme files.
Script :
var res = Drive.Files.list({
q: "sharedWithMe",
fields: "items(id,shared,sharedWithMeDate,title)"
});
Logger.log(JSON.stringify(res))
Result :
{
"items": [
{
"id": "#####",
"sharedWithMeDate": "Time that the file was shared with the user",
"shared": true,
"title": "File name"
}
]
}