Last Published (code embed) feature not showing correct date/time

I have an embedded custom code element in my nav symbols element, this parent element is fixed to the top of every page. The embedded code is intended to reference the last published time. However, the JS code currently reflects the time which the website was last loaded/refreshed.

How can I change this to reflect the time of last published from Webflow? Is this possible?

Cheers!


Here is my site Read-Only: LINK
(how to share your site Read-Only link)

Using the last last-modified header as a source is not the best idea. I don’t know how WF infrastructure is set up, I couldn’t even find the header on the initial raw document, only on assets like js and css files. I don’t know how the cashing is set up and WF renders your site server-side.

You’d be better off hardcoding it in your site or using the html comment that is on every WF site:

image

I found this post on stackoverflow

var findComments = function(el) {
    var arr = [];
    for(var i = 0; i < el.childNodes.length; i++) {
        var node = el.childNodes[i];
        if(node.nodeType === 8) {
            arr.push(node);
        } else {
            arr.push.apply(arr, findComments(node));
        }
    }
    return arr;
};

var commentNodes = findComments(document);

This will output the last published date, but you’ll need to get the date out of the string.

console.log(commentNodes[1].nodeValue);