ITworld.com
  Search  
ITworld Home Page ITworld Webcasts ITworld White Papers ITworld Newsletters ITworld News ITworld Topics Careers ITworld Voices ITwhirled Changing the way you view IT
Informing Visitors of a Change Date A property of the Document object makes it easy
JAVASCRIPT --- 09/17/2002

David Wall

The Document Object Model that we manipulate in JavaScript includes a property that identifies the date and time the current document was changed. If, in your code, you make a reference to document.lastModified, you'll get a Date object (which you can just print as a text string) indicating the relevant point in history. 

On this topic

A simple usage of the property looks like this:

document.write(document.lastModified)

Though precise formats vary among browsers and localities that code will yield something like this:

08/12/2002 17:36:32

That is, it returns a mm/dd/yyyy date and hh:mm:ss time. The date and time come from the operating system, and usually won't change if you open, save, and close a file without modifying it. You can extract bits and pieces of the date and time easily because it's a Date object. Use the Date.getDate(), Date.getMonth(), and Date.getYear() methods to pull out the pieces you want and reassemble them as you wish.

You'll find an application that uses the document.lastModified property, complete with a utility that formats the date nicely and gets around turn-of-the-millennium problems, here: http://www.chami.com/tips/internet/041198I.html

 

David Wall works as a freelance writer, programmer, lecturer, and consultant. Based near Washington, D.C., David has written and co- written several books, including Graphics Programming with JFC. David can be reached at David.Wall@itworld.com.



Advertisements
Sponsored links
Top 5 Reasons to Combine App Performance and Security
Locate Hidden Software on business PCs with this free tool
KODAK i1400 Series Scanners stand up to the challenge
Bring harmony to your mix of UNIX-Linux-Windows computing environments
 Home   Newsletters  JAVASCRIPT
www.itworld.com    open.itworld.com     security.itworld.com     smallbusiness.itworld.com
storage.itworld.com     utilitycomputing.itworld.com     wireless.itworld.com

 
Contact Us   About Us   Privacy Policy    Terms of Service   Reprints  

CIO   Computerworld   CSO   GamePro   Games.net   IDG Connect   IDG World Expo   Industry Standard   Infoworld   ITworld   JavaWorld   LinuxWorld  MacUser   Macworld   Network World   PC World   Playlist  

Copyright © Computerworld, Inc. All rights reserved

Reproduction in whole or in part in any form or medium without express written permission of Computerworld Inc. is prohibited. Computerworld and Computerworld.com and the respective logos are trademarks of International Data Group Inc.