I want to change the year of the whole site, temporarily, from 2018 to 2019.

So the year of the_time() has to be 2019.

There are no plugins which can do this...

How can this be done ?

1 Answer 1


If you want to do this temporarily that means you want to be able to switch back later, right? That in turn means you don't want to change the values in the database. So you want the_time to change after it has retrieved the value from the database, but before it is presented to the user. Luckily the_time has a filter for that. Like this

add_filter ('the_time','wpse303207_change_year');

function wpse303207_change_year ($time) {
   // do your thing

Because the_time returns a string that depends on the time format you have chosen, you'll have to sort out yourself how to use str_replace to change the date inside the time string.

This would also work for the_date, by the way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.