Chrome, Safari and document.lastModified

Perhaps I'm reinventing the wheel, but still. I was wondering why Safari and Chrome fail to correctly insert a string with the last modification date at the bottom of my pages. As usual, I've set up a test to check out what's wrong.

Surprisingly, both Chrome and Safari support the lastModified property of the document object only when the page is on a web server. However, they still fail to insert a date created as a timestamp from lastModified. I think this is somewhat related with a couple of problems that affected older versions of Webkit, mainly due to some obscure details of the implementation of the Date object (Safari 3 returned NaN, for example).

So they don't display the timestamp and I think that I'll have to make some further tests to fix this problem. Stay tuned!

2 thoughts on “Chrome, Safari and document.lastModified”

  1. Nope. Basically, JavaScript has no built-in functions to handle timestamps as it happens to PHP. The fact is that lastModified is a String, not a Date type. So the best thing you can do is to write a function to extract the relevant parts of the string and then format them. HTH. Bye and thanks for the comment!

Leave a Reply

Note: Only a member of this blog may post a comment.