Home > Backend Development > PHP Tutorial > Carbon-based time travel Travel expansion pack

Carbon-based time travel Travel expansion pack

Guanhui
Release: 2023-04-08 17:04:02
forward
2581 people have browsed it

Carbon-based time travel Travel expansion pack

Travel is a small php extension provided and maintained by Rachid Laasri, which uses Carbon to help you perform certain operations back to a specific time and return.

Travel::to('November 5, 1955');
// Stop Biff
// 回到某天
Travel::to('October 26, 1985');
Copy after login

The following is an example of executing some time-sensitive code in a closure and returning the current time after the execution is completed:

Travel::to('-5 minutes', function() {
    // 逻辑代码
});
Copy after login

If you have already used time travel, please do not Forgot to execute the following method to return the current point in time.

Travel::back();
Copy after login

For details, please check GitHub rashidlaasri/travel

Recommended tutorial: "PHP Tutorial"

The above is the detailed content of Carbon-based time travel Travel expansion pack. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template