Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Ok I must be missing something. I have a section with the "last updated date" in a text cell, I'd like it to autoupdate. Is there a "insert current date" command hidden away in some menu?


How can I automatically insert the current date and time into a notebook each time I save it to indicate the date and time last modified?

share|improve this question

If you want this done automatically then the way I would do it is to time stamp the notebook as you close it, i.e. the time stamp appears after "Last modified".

This code might be overkill but it will do the job:

Create a text cell with "Last Modified " in it and give it a cell tag (in this example "LastModified"), then ...

 NotebookEventActions :> {"WindowClose" :> 
    Module[{dy, hr, mn}, {dy, hr, mn} = 
      Map[(LinkWrite[First[$FrontEnd], FrontEnd`Value[#]]; 
             LinkRead[First[$FrontEnd]]) &, {"DateLong", "Hour", 
        "Minute"}]; NotebookLocate["LastModified"]; 
      Cell[TextData[{"last modified ", dy, " at ", hr, ":", mn}], 
       "Text", CellTags -> "LastModified"]]]}
share|improve this answer
Mike, I was about to delete this question in routine clean-up. If you care to edit the question in a bid for reopening do so now, please. – Mr.Wizard Jun 26 '15 at 18:37
@Mr.Wizard lucky I saw this. Have not been on here very much in recent weeks. I wasn't quite sue what you meant but have modified the question – Mike Honeychurch Jun 26 '15 at 23:26
I am glad you could reply. I hope that whatever is occupying your time is either enjoyable or profitable for you. :-) Your edit seems good enough to me so I reopened the question. Thanks. – Mr.Wizard Jun 27 '15 at 3:19

If you want to see when the notebook was last changed you could also use the information that is collected by the "Notebook History" functionality (of course only when you did not disable that functionality in the Advanced tab of the preferences). The following creates a cell which automatically keeps track of any change times, whether or not they have been saved to file:

  Row[{"Last Change: ", Dynamic[
     Cases[NotebookGet[], Verbatim[Rule][CellChangeTimes, v_] :> v, 
  ], UpdateInterval -> 10]}]

you could of course use similar code to update a cell only when the notebook is closed like Mike has shown or use an explicit update button to do the update. Another alternative would be to creat your own palette/docked cell with a save button which would determine the newest CellChangeTimes value of the given notebook, write it to the notebook and save after that. Unfortunately there is no hook to do this on "NotebookSave" (as for "WindowClose") AFAIK...

share|improve this answer

If you want the message to show when you last run that command, all you have to do is add this to the cell you're evaluating:

message = DateString[DateList[]]  ;
Print["This was last updated on  " <> message]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.