Now this looks handy, especially when you’re writing/testing code that’s dependent on the system’s time:
php-timecop
is a PHP extension providing “time travel” and “time freezing” capabilities
- Freeze time to a specific point.
- Travel back to a specific point in time, but allow time to continue moving forward from there.
- Scale time by a given scaling factor that will cause time to move at an accelerated pace.
- Override time-related PHP stock functions and methods, which supports freezing or traveling time.
var_dump(date("Y-m-d")); // todays date
timecop_freeze(0);
var_dump(gmdate("Y-m-d H:i:s")); // string(19) "1970-01-01 00:00:00"
var_dump(strtotime("+100000 sec")); // int(100000)
php-timecop
→
Stub PHP date()
and the crew with php-timecop
→