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>

Peter Grainge
Community Expert
Community Expert
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

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