dousi0144 2017-08-10 13:45
浏览 20

克隆的DateTime更改值

I have a value, a DateTime that I clone and without touching it in a foreach I display it again. But without any clue the value has changed. I know it's from the:

if ($rtt->getPrttDateDebutPose()<$conge->getCngDateDebut() || $poseRTTService->getDateLastDay($rtt)>$conge->getCngDateFin()) {

Because I tested it, it's what can possibly change the value (even though I can't figure why either). But a clone ? Why would it change I don't do anything with it ?

Here's the complete code :

$end_rtt = clone end($RTT_pris);
var_dump($end_rtt); // -------------------------------------------------------------------------------------
// Algo that allows to separate in two arrays the conges w/ rtt and those w/o
foreach ($conges as $conge) {
    $count = 0;
    foreach ($RTT_pris as $rtt) {
        if ($rtt->getPrttDateDebutPose()<$conge->getCngDateDebut() || $poseRTTService->getDateLastDay($rtt)>$conge->getCngDateFin()) {
            $count++;
        }
    }
    if ($count == count($RTT_pris) && !in_array($conge, $conges_final)) {
       array_push($conges_final, $conge);
    } else {
        array_push($conges_w_rtt, $conge);
    }
}
var_dump($end_rtt); // ---------------------------------------------------------------------------------------

And here's the output of the two var_dump($end_rtt) :

enter image description here

See how the date pass from 11 to 20.

If anyone understands that, do please explain.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 关于大棚监测的pcb板设计
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
    • ¥15 Vue3地图和异步函数使用