3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getPrevMonthDatetime($datetime) { return date('Y-m-d H:i:s', strtotime('today last month 00:00:00', strtotime($datetime))); } for ($datetime = '2016-01-01 00:00:00'; strtotime($datetime) < strtotime('2017-01-01 00:00:00'); $datetime = date('Y-m-d H:i:s', strtotime($datetime)+60*60*24)) { echo $datetime.' -> '.getPrevMonthDatetime($datetime)."\n"; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 2
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 2
Branch analysis from position: 26
Branch analysis from position: 2
filename:       /in/2P9kj
function name:  (null)
number of ops:  27
compiled vars:  !0 = $datetime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN                                                   !0, '2016-01-01+00%3A00%3A00'
          1      > JMP                                                      ->18
   10     2    >   CONCAT                                           ~2      !0, '+-%3E+'
          3        INIT_FCALL                                               'getprevmonthdatetime'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $3      
          6        CONCAT                                           ~4      ~2, $3
          7        CONCAT                                           ~5      ~4, '%0A'
          8        ECHO                                                     ~5
    9     9        INIT_FCALL                                               'date'
         10        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         11        INIT_FCALL                                               'strtotime'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $6      
         14        ADD                                              ~7      $6, 86400
         15        SEND_VAL                                                 ~7
         16        DO_ICALL                                         $8      
         17        ASSIGN                                                   !0, $8
         18    >   INIT_FCALL                                               'strtotime'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                         $10     
         21        INIT_FCALL                                               'strtotime'
         22        SEND_VAL                                                 '2017-01-01+00%3A00%3A00'
         23        DO_ICALL                                         $11     
         24        IS_SMALLER                                               $10, $11
         25      > JMPNZ                                                    ~12, ->2
   11    26    > > RETURN                                                   1

Function getprevmonthdatetime:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2P9kj
function name:  getPrevMonthDatetime
number of ops:  14
compiled vars:  !0 = $datetime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'date'
          2        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
          3        INIT_FCALL                                               'strtotime'
          4        SEND_VAL                                                 'today+last+month+00%3A00%3A00'
          5        INIT_FCALL                                               'strtotime'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $1      
          8        SEND_VAR                                                 $1
          9        DO_ICALL                                         $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                         $3      
         12      > RETURN                                                   $3
    6    13*     > RETURN                                                   null

End of function getprevmonthdatetime

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.47 ms | 1403 KiB | 18 Q