Skip to main content
Inspiring
April 30, 2010
Question

Date Last Updated

  • April 30, 2010
  • 1 reply
  • 1326 views

I'm using RoboHelp HTML 8. I've added a date last updated footer to my pages (borrowing the JavaScript for the date last updated from Peter Grainge's excellent site). What I'd like it to do is to display the date I actually made a change to each page and saved it. Unfortunately, it appears that each time I generate/publish my project, all of the pages have their last modified date updated to the date of publication. That means that all the pages show the date of publication as the the date last updated, even if they weren't changed. Is there any way to avoid that?

In the Generate dialog box, I don't have Republish All checked. I'm sure there must be some other setting that I'm overlooking.

This topic has been closed for replies.

1 reply

Peter Grainge
Community Expert
Community Expert
April 30, 2010

Where is that script on my site?


See www.grainge.org for RoboHelp and Authoring tips

@petergrainge

Use the menu (bottom right) to mark the Best Answer or Highlight particularly useful replies. Found the answer elsewhere? Share it here.
LarryTXAuthor
Inspiring
April 30, 2010

Sorry, Peter, I confused the date last modified script with another one that I got from your site. Anyway, the script that I'm using does indeed return the date last modified as reported in Windows Explorer. The problem is not the script; it's that the file's last modified date is changed to the current date in the publication process, which is what shouldn't happen.

For what it's worth. I'm reproducing the script below. It's one everyone should have.

<script
  type="text/JavaScript"
  language="JavaScript">
<!--
//
// format date as dd-mmm-yy
// example: 12-Jan-99
//
function date_ddmmmyy(date)
{
  var d = date.getDate();
  var m = date.getMonth() + 1;
  var y = date.getYear();

  // handle different year values
  // returned by IE and NS in
  // the year 2000.
  if(y >= 2000)
  {
    y -= 2000;
  }
  if(y >= 100)
  {
    y -= 100;
  }

  // could use splitString() here
  // but the following method is
  // more compatible
  var mmm =
    ( 1==m)?'Jan':( 2==m)?'Feb':(3==m)?'Mar':
    ( 4==m)?'Apr':( 5==m)?'May':(6==m)?'Jun':
    ( 7==m)?'Jul':( 8==m)?'Aug':(9==m)?'Sep':
    (10==m)?'Oct':(11==m)?'Nov':'Dec';

  return "" +
    (d<10?"0"+d:d) + "-" +
    mmm + "-" +
    (y<10?"0"+y:y);
}


//
// get last modified date of the
// current document.
//
function date_lastmodified()
{
  var lmd = document.lastModified;
  var s   = "Unknown";
  var d1;

  // check if we have a valid date
  // before proceeding
  if(0 != (d1=Date.parse(lmd)))
  {
    s = "" + date_ddmmmyy(new Date(d1));
  }

  return s;
}

//
// finally display the last modified date
// as DD-MMM-YY
//
document.write(
  "This page was updated on " +
  date_lastmodified() );

// -->
</script>

LarryTXAuthor
Inspiring
April 30, 2010

My lawyers will be in touch about the false accusation.

When the script is run it will look at the file it is in.

In the generated files, they are always new so you will get one date if you examine those. However, if you look at the published files as you don't have Republish All, their modified date will be the last time that file was generated with new content, which is what you want.

Have you looked at the server file attributes to ensure the modified date is correct?

Not sure why everyone should have this script if it doesn't work.


See www.grainge.org for RoboHelp and Authoring tips

@petergrainge


Actually, the script does exactly what it's supposed to do -- report the file's Last Modified date. The problem may be in my understanding of generate vs. publish. Here's the way I understand it:

  • Publish essentially just copies files from one place to another. Granted, if you need additional services such as an FTP login, it provides addition support, but it is, at its core, a copy mechanism.
  • Generate goes through all the files in a project, replacing any RoboHelp-specific notation, such as snippets, UDVs, headers and footers, etc., with their HTML equivalents. In the process, it changes all of the files, changing their Date Modified in the process.
  • There appears to be no way to generate a single file. So if you make changes to a single file in a project that includes any RoboHelp-specific notation, you must generate the entire project resulting in all the files being updated.
  • Therefore, if you have a Date Last Updated footer in all the files and make a change to a single file, thus being forced to generate the entire project, your readers will be falsely informed that the content of every single topic was updated.

Help me understand if I portrayed the scenario incorrectly. I really would like to avoid the last bulleted item. My Date Last Updated should accurately reflect the date that an actual change in content was made to the content of a topic. My readers have no need or desire to know when I last generated the entire project. They want to know, "How current is the information in this topic?" There should be a way to have this automatically done. To have to do it manually on every single edited topic is not only onerous; it is also error-prone. I'm really hoping that there's a way around this publish/generate conundrum.