Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 928311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:59:25+00:00 2026-05-15T19:59:25+00:00

Is it possible to make a PHP application think that the server datetime is

  • 0

Is it possible to make a PHP application think that the server datetime is offset by a large configurable amount (like 6 months ago, or 6 months from now)?

Background:
We have a web application that deals with sporting events and right now we would like to run it in our development environment in such a way that the web site thinks it is Fall 2009 instead of Summer 2010. That’s because we have great data from last year’s Fall season and this year’s season has not yet started, so testing new features would be easier with scads of real data instead of making up new test data for 2010.

We don’t want to actually change the server’s date and time. The current best option seems to be to change all date() calls in the code to my_date() and then have my_date() add the offset to the actual system date.

It seemed like this feature would be useful in similar situations for others, so I was just curious if there’s an easier way to do it globally through some configuration parameter without modifying code. I did RTM.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:59:25+00:00Added an answer on May 15, 2026 at 7:59 pm

    You could install Runkit on the Development server and redefine all required dateTime functions to return a modified value, e.g.

    if(APP_ENV === 'testing') {
        include 'datetime-monkeypatches.php';
    }
    

    where datetime-monkeypatches.php would contain your patches to the required functions. This way you wouldnt have to change your actual code. It’s like using an adapter to the original functions and as long as you keep them in that separate file, it stays maintainable.

    Another option would be to use http://antecedent.github.io/patchwork

    Patchwork is a PHP library that makes it possible to redefine user-defined functions and methods at runtime, loosely replicating the functionality runkit_function_redefine in pure PHP 5.3 code, which, among other things, enables you to replace static and private methods with test doubles.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to make a web application (PHP) that will have overlay container
i have mysql that is used on production server for php webshop application. sometimes
Possible Duplicate: Make PHP execute and communicate with a Java application on a web
Is it possible to make php variables public and accessible anywhere on the timeline?
Is it possible to make changes in mysql's my.ini file using PHP script?
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Is it possible make some handler that will do something when user shutdown computer
Is it possible make an activity, that will lock the android device? That device
Yes, it's a newb question. I want to make a timetabling application that these
I am writing a PHP application that's supposed to allow users to add certain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.