# timeoffset per process

- Thread: https://externals.io/message/14772
- Original archive: https://news-web.php.net/php.internals/14772
- Started by Lukas Smith on 2005-02-09T20:38:10+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #14772 — Lukas Smith — 2005-02-09T20:38:10+00:00

URL: https://externals.io/message/14772#14772

Hi,

I am currently writing test cases for time sensitive code. Meaning this 
code behaves different depending on the time of day. Obviously one 
solution is to mess with the server time, but that is going to screw up 
anything else going on the server.

The only solution that I have currently come up with requires alot of 
uglyness by making my code call a wrapper function instead of `time()` or 
 `date()` which optionally adds an offset to the time that can be set 
before executing the tests.

It seems like a minor feature to add to the date extension. But then 
again I can understand that Derick doesnt feel features for testing fits 
into the new date extension. Am I missing an obvious alternative? Is 
there a better place to add this feature?

regards,
Lukas

---

## #14773 — Jochem Maas — 2005-02-09T20:50:09+00:00

URL: https://externals.io/message/14772#14773 · In reply to: #14772

Lukas Smith wrote:
> Hi,
> 
> I am currently writing test cases for time sensitive code. Meaning this 
> code behaves different depending on the time of day. Obviously one 
> solution is to mess with the server time, but that is going to screw up 
> anything else going on the server.
> 
> The only solution that I have currently come up with requires alot of 
> uglyness by making my code call a wrapper function instead of `time()` or 
> `date()` which optionally adds an offset to the time that can be set 
> before executing the tests.
> 
> It seems like a minor feature to add to the date extension. But then 
> again I can understand that Derick doesnt feel features for testing fits 
> into the new date extension. Am I missing an obvious alternative? Is 
> there a better place to add this feature?

maybe install a test setup on your local machine?
then you can mess with the local time, no problems?

rgds,
Jochem

> 
> regards,
> Lukas

---

## #14774 — Lukas Smith — 2005-02-09T20:53:36+00:00

URL: https://externals.io/message/14772#14774 · In reply to: #14773

Jochem Maas wrote:
> Lukas Smith wrote:
> 
> > […]
> 
> 
> maybe install a test setup on your local machine?
> then you can mess with the local time, no problems?

this is what I do now, but obviously its far from ideal, especially 
since you also want to be able to run your tests on your production 
server to check if the install went fine or when bugs are reported.

regards,
Lukas

---

## #14775 — Jochem Maas — 2005-02-09T21:01:54+00:00

URL: https://externals.io/message/14772#14775 · In reply to: #14774

Lukas Smith wrote:
> Jochem Maas wrote:
> 

...

> > […]
> 
> 
> this is what I do now, but obviously its far from ideal, especially 
> since you also want to be able to run your tests on your production 
> server to check if the install went fine or when bugs are reported.

yeah, sorry wrong list. I thought I was answering on generals :-/
my apologies. (should have recognized the name.)

> 
> regards,
> Lukas
