Nur Filed Date oder sowohl Filed Date als auch Modified Date anzeigen [von David Watts]
Folgender Code zeigt entweder nur das "Filed date" an (wenn der Artikel nicht modifiziert wurde) oder sowohl "Filed date" als auch "Modified date" (falls beide unterschiedliche sind).
Das Ergebnis ist entweder
Published Sun 12/21/03 02:57 PM
oder
First published Sat 10/11/03 09:44 PM. Updated Sun 12/21/03 03:18 PM
Fügen Sie einfach diesen Code in Ihren Artikel oder Ihr Template ein (oder als Variable):
<SCRIPT LANGUAGE="JavaScript">
<!--
{$setDateTimeFormat "English" "MMMM dd, yyyy" "HH:mm:ss"$} // the format that the Date method requires
filedDate=new Date("{$ .filedDate $}")
modifiedDate=new Date("{$ .modifiedDate $}")
{$setDateTimeFormat "English" "ddd M/dd/yy" "hh:mm tt"$} // the format to print
with (document) {
if (Date.parse(filedDate) == Date.parse(modifiedDate))
write("<p>Published {$ .filedDate $} {$ .filedTime $}</p>")
else
write("<p>First published {$ .filedDate $} {$ .filedTime $}. Updated {$ .modifiedDate $} {$ .modifiedTime $}</p>")
}
//-->
</SCRIPT>




