Display the File Last Updated Date Using jQuery in SharePoint

In this example, assume there is a dashboard page on a SharePoint site that displays a number of graphs and charts. This dashboard is based on data contained in a single file located in a document library on the same site. Whenever this file is updated, the last modified date of the file needs to be automatically reflected on the dashboard page. This allows the page viewer to know the freshness of the dashboard data without requiring the content owner to edit the dashboard page itself with every data change. The following code will display the file last updated date using jQuery, the SharePoint Client Object Model (sp.js), and a bit of HTML. The formatDate function is used to format the file last modified timestamp in dd-mon-yyyy format.

Add a Content Editor Web Part to the dashboard page and include the following script in the source (or as a reference to a script file).

Change the FileUrl variable in getFileInfo() to the appropriate file path. When the code executes, it will replace the contents of the “data_last_update_date” container with the formatted last modified timestamp.

5 thoughts on “Display the File Last Updated Date Using jQuery in SharePoint”

  1. Hi John – Your use case describes my needs…exactly. I followed the instructions to the ‘t’, but the container is empty. I’m using SP 2013. Any ideas?

  2. I couldn’t tell you specifically, but I would put in some alerts throughout the code to make sure that the code is running and returning the expected result within each of the functions.

  3. Hi John, great script you’ve developer here, I would like to use it multiple times on a SharePoint site Wiki page, but it only works for one file, I have a matrix of 8 files where I want to show last updated data for each of them on one page, changing the div ID doesn’t work, can you help me fix this issue?

  4. Hi John, this code came in very handy, thank you! I’d like to know if is there a way to return the user who modified the file?

Leave a Comment