Supposing a Linux system is used, one can use the date
function to set the date directly. One then has
$aDate = getdate();
...
do something else
...
exec("/bin/date ".sprintf("%02d",$aDate["mon"]).sprintf("%02d",$aDate["mday"]).
sprintf("%02d",$aDate["hours"]).sprintf("%02d",$aDate["minutes"]).sprintf("%04d",$aDate["year"]).
".".sprintf("%02d",$aDate["seconds"]));
If the date is changed in-between, this does not matter as it will be set back to the time before the intermediate steps.
Remarks:
- The inter-between processing should not take too much time, as the time afterwards will be wrong. If the processing is less than a second, this should be fine
- Although the use of exec poses a security risk, the above usage is safe IF AND ONLY IF the variable
$aDate
is not tampered with inbetween.