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

  • Home
  • SEARCH
  • 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 3222408
In Process

The Archive Base Latest Questions

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

Is it possible to change php’s current date and time (something like set_time(strtotime(‘1999-09-09’)) so

  • 0

Is it possible to change php’s current date and time (something like set_time(strtotime(‘1999-09-09’)) so when i call time() it will return me timestamp for 1999-09-09? I need to set it globally for whole app.

EDIT

I already have one old app and i need to make possible to set up current date.
I can’t accept any custom functions. Imagine i should review all the code and replace every time() call. Even if i’ll do so then it will not help because there are functions like getdate() which i need to replace as well.

  • 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-17T15:59:16+00:00Added an answer on May 17, 2026 at 3:59 pm

    The time() functions actually asks the system clock for the time, so you’d have to update the time of the server’s system clock. A few things to keep in mind:

    • This is done differently on a Unix server than a Windows server. If you want code compatible with both, you have to be careful
    • Sometimes (especially in shared hosting situations) you aren’t allowed to change the system time
    • Changes to system time will remain after the script has executed unless you change it back later. Therefore you risk really screwing up the system clock.

    If you want to change the time globally for an entire app, I recommend having a static variable $timeOffset and create your own time() function as follows:

    function myTime(){
        global $timeOffset;
        return time()+$timeOffset;
    }
    

    If you’ve taken all of that into account and still want to change the system time, however, you would need to send a command to the shell using shell_exec()

    In Windows, the code would look like this:

    shell_exec("date 09-09-99"); // Use "date mm-dd-yy" or "time hh:mm:ss", respectively
    

    In UNIX, according to the date man page, the code would look like:

    shell_exec("date 0909hhmm1999"); // It says "date MMDDhhmiYYYY". I'm not sure how to set seconds, although I assume "mi" = "minutes"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to change the current 24 hr format like 22:16:08 to something
Is it possible to place code in the 404.php file which will change elements
Possible Duplicate: How to change appearance of URL from within a PHP script I
Possible Duplicate: In PHP, how do you change the key of an array element?
Possible Duplicate: Change icon on of an App in iOS 4 in run-time Is
anyone has idea if and how is it possible to destroy / change php
Possible Duplicate: Change single variable value in querystring I'm retrieving the current URL: http://example.com/?s=original&fq=category
I'm not even sure if its possible, but I'd like to change the value
Wondering how I can change the php session id from PHPSESSID to something else
NetBeans uses PHP Smarty Framework plugin for *.tpl files. Is it possible to change

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.