3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set('Europe/Moscow'); function humanTimeAgo(int $time) { if ($time < 0) { return false; } $difference = time() - $time; if ($difference < 0) { return false; } $hours = round($difference / 3600); if ($hours < 1) { return date('i минут назад', $difference); } if ($hours < 24) { return $hours . ' часов назад'; } return date('d.m.Y в H:i', $time); } echo humanTimeAgo(time() - 24*3600 - 10*60); // 1 день и 10 минут назад echo "\n"; echo humanTimeAgo(time() - 23*3600 - 20*60); // 23 часа 20 минут назад echo "\n"; echo humanTimeAgo(time() - 10*60); // 10 минут назад
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ijk8j
function name:  (null)
number of ops:  29
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'date_default_timezone_set'
          1        SEND_VAL                                                 'Europe%2FMoscow'
          2        DO_ICALL                                                 
   30     3        INIT_FCALL                                               'humantimeago'
          4        INIT_FCALL                                               'time'
          5        DO_ICALL                                         $1      
          6        SUB                                              ~2      $1, 86400
          7        SUB                                              ~3      ~2, 600
          8        SEND_VAL                                                 ~3
          9        DO_FCALL                                      0  $4      
         10        ECHO                                                     $4
   31    11        ECHO                                                     '%0A'
   32    12        INIT_FCALL                                               'humantimeago'
         13        INIT_FCALL                                               'time'
         14        DO_ICALL                                         $5      
         15        SUB                                              ~6      $5, 82800
         16        SUB                                              ~7      ~6, 1200
         17        SEND_VAL                                                 ~7
         18        DO_FCALL                                      0  $8      
         19        ECHO                                                     $8
   33    20        ECHO                                                     '%0A'
   34    21        INIT_FCALL                                               'humantimeago'
         22        INIT_FCALL                                               'time'
         23        DO_ICALL                                         $9      
         24        SUB                                              ~10     $9, 600
         25        SEND_VAL                                                 ~10
         26        DO_FCALL                                      0  $11     
         27        ECHO                                                     $11
         28      > RETURN                                                   1

Function humantimeago:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 23
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 27
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ijk8j
function name:  humanTimeAgo
number of ops:  33
compiled vars:  !0 = $time, !1 = $difference, !2 = $hours
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        IS_SMALLER                                               !0, 0
          2      > JMPZ                                                     ~3, ->4
    8     3    > > RETURN                                                   <false>
   11     4    >   INIT_FCALL                                               'time'
          5        DO_ICALL                                         $4      
          6        SUB                                              ~5      $4, !0
          7        ASSIGN                                                   !1, ~5
   13     8        IS_SMALLER                                               !1, 0
          9      > JMPZ                                                     ~7, ->11
   14    10    > > RETURN                                                   <false>
   17    11    >   INIT_FCALL                                               'round'
         12        DIV                                              ~8      !1, 3600
         13        SEND_VAL                                                 ~8
         14        DO_ICALL                                         $9      
         15        ASSIGN                                                   !2, $9
   19    16        IS_SMALLER                                               !2, 1
         17      > JMPZ                                                     ~11, ->23
   20    18    >   INIT_FCALL                                               'date'
         19        SEND_VAL                                                 'i+%D0%BC%D0%B8%D0%BD%D1%83%D1%82+%D0%BD%D0%B0%D0%B7%D0%B0%D0%B4'
         20        SEND_VAR                                                 !1
         21        DO_ICALL                                         $12     
         22      > RETURN                                                   $12
   23    23    >   IS_SMALLER                                               !2, 24
         24      > JMPZ                                                     ~13, ->27
   24    25    >   CONCAT                                           ~14     !2, '+%D1%87%D0%B0%D1%81%D0%BE%D0%B2+%D0%BD%D0%B0%D0%B7%D0%B0%D0%B4'
         26      > RETURN                                                   ~14
   27    27    >   INIT_FCALL                                               'date'
         28        SEND_VAL                                                 'd.m.Y+%D0%B2+H%3Ai'
         29        SEND_VAR                                                 !0
         30        DO_ICALL                                         $15     
         31      > RETURN                                                   $15
   28    32*     > RETURN                                                   null

End of function humantimeago

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.25 ms | 1402 KiB | 24 Q