hboss22 Posted March 7, 2021 Posted March 7, 2021 Hi @paul2009 Im looking to see if the dates for my blog posts throughout the site (in summary blocks, blog pages and individual blog posts) can read "1 day ago" or "5 days ago" or "1 month ago" instead of showing the actual date of the post. Is this possible? Website: http://www.fromyourmuse.com Password: musings2 Beyondspace 1
Solution paul2009 Posted March 7, 2021 Solution Posted March 7, 2021 (edited) There isn't a built-in feature that does this. If you are familiar with JavaScript (or you hire a developer who is) then a solution could be written to do this in JavaScript (assuming the site is on a Business Plan or above). In summary, you'll first need to use JS to extract the date of each post and calculate the number of seconds between then and now. If it is less than 60 seconds you'd substitute "X seconds ago", if it is less than 3600 you substitute "X minutes ago" and so on. The script should be added to the Code Injection Footer so that it runs after the blog post(s) have loaded, allowing the dates to be modified. Edited January 4, 2023 by paul2009 Me: I'm Paul, a SQSP user for >18 yrs & Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥. Work: Founder of SF.DIGITAL. We provide high quality original extensions to supercharge your Squarespace website. Content: Views and opinions are my own. Links in my posts may refer to my own SF.DIGITAL products or may be affiliate links. Forum advice is completely free. You can thank me by selecting a feedback emoji. Buying a coffee is generous but optional.
hboss22 Posted March 8, 2021 Author Posted March 8, 2021 @paul2009 ahh I see. So it's not necessarily something that can be done once that will apply to every blog post. I'd have to do this for every single post?
paul2009 Posted March 8, 2021 Posted March 8, 2021 The code would be written to look for every blog post date on the page and modify it as described. Me: I'm Paul, a SQSP user for >18 yrs & Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥. Work: Founder of SF.DIGITAL. We provide high quality original extensions to supercharge your Squarespace website. Content: Views and opinions are my own. Links in my posts may refer to my own SF.DIGITAL products or may be affiliate links. Forum advice is completely free. You can thank me by selecting a feedback emoji. Buying a coffee is generous but optional.
creedon Posted January 4, 2023 Posted January 4, 2023 3 hours ago, hercegovka said: What is the CSS code to convert dates to show age - like "3 days ago?" CSS can not be used to convert text. You would need JavaScript. I am unaware of any code that does this. ivanarevic 1 Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment