Reputation: 5727
I'm currently working on my company's in-house CMS and wish to add the ability for an admin to view the site on a specific date. This will allow admins to preview the site with archived or scheduled posts.
I'd like to avoid finding all mentions of date()
or time()
and offsetting them. Is there a way of making PHP think it's a specific date so that all calls to date()
default to the new time?
Thank you
Upvotes: 2
Views: 545
Reputation: 11855
I can only think of changing it globally, which would change the date for everyone on the server at that point.
I would probably store a timestamp in the session or similar, so that it can be easily changed and updated at will, rather than changing core php ini values.
Upvotes: 1
Reputation: 11515
This sounds like an encapsulation issue -- why not search for all mentions of date()
or time()
and replace them with $site->getDisplayedDate()
, or something else appropriate to your code?
Upvotes: 1