First, Happy New Year to everyone!
Secondly, the InfinityFree front page has a small year issue.
Now it’s already 2024.
Happy holidays to everyone!
remove the fixed text and add some php code to display the server year
Or use JS
how would i do that?
You can use Javascript to dynamically set the year using this new Date().getFullYear();
function.
For exapmle i created this script to change my website’s year dynamically.
let gtm = new Date().getFullYear();
function exon() {
dt.setAttribute('data-dt', gtm);
}
exon();
function dtex(){
let dtl = dt.getAttribute('data-dt');
dt.innerText = dtl;
}
dtex();
Hmm, I thought I fixed that. But apparently I didn’t.
I thought I had setup an automatic pipeline that runs on January 1st just after midnight that rebuilds and re-publishes the site with the new year. The date is actually dynamic, but only in the site generator, the site itself is completely static.
And having dynamic code to that calculates the year on every request seems a bit unnecessary for something that only changes once per year. Especially if that would be the only reason to have server side rendering.
Oh i haven’t thought about it. I’ll set it to only be executed on January 1st.
Maybe you had it back when you were using Jekyll
and when you changed the website (design + hugo) then you forgot about it
Unless most of your page has PHP code, then I don’t see the point in doing that.
PHP would probably be better because you only need to use one line, whereas Javascript would take multiple.
The year is <?= date("Y") ?>!
I also noticed that, with the new change, the website’s font is also broken!
Yes except that means consuming a bit of server power to calculate it when you want it to spit out static web page (which is done without executing anything)
Thanks, I hadn’t noticed yet!
I enabled CSP on the main site today based on older config, but it had an incorrect font-src which didn’t allow the current Google fonts. That’s fixed now.
No problem, I just had to point it out! Anyway now the fonts load as usual.
True. But my page is a static one
Then use JS. JS is very good for this case and it can work more flexible.
There is really no need to bloat the web page a little just to make it change something that happens once a year, really.
Hi YT_Xaos,
There’s a bit of difference between PHP and JS for copyright year due to different clocks being used as reference.
PHP is definitely server-time based, and while you can guess the user’s geographical location by IP address, you could still be misaligned to the user’s timezone or be completely wrong if you simply converted the year based on that. Usually, websites that go with PHP are server-time oriented and have the time set to follow the company location.
JavaScript on the other hand gives a more customized user experience and caters to all users of all timezones, as they are the ones keeping their clocks accurate. However weird cases like some dude setting the clocks years ahead or before (probably for Candy games) and will see an odd year displayed.
For hosting company like IF, definately PHP as that’s what reflects the hosting location and the company location. For blogs tho, either solution works depending on the web admin’s niche.
Cheers!
It really doesn’t matter what you use to update the year. Quite frankly, most users will either not notice or not care.
Yes, exactly.
change the copyright year to the infinity symbol, problem solved
This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.