开发者

Set the current date in PHP

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开发者_StackOverflow中文版 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


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?


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.

You might try this though

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜