3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set( 'UTC' ); function micro_time_precise_date_time_immutable( $microTime ) { $timestamp = (int) floor($microTime); $u = sprintf("%06d", ($microTime - $timestamp) * 1000000); return DateTimeImmutable::createFromFormat( 'Y-m-d H:i:s.u', date( 'Y-m-d H:i:s.'.$u, $timestamp ) ); } $mt = microtime( TRUE ); $a = DateTimeImmutable::createFromFormat('U.u', sprintf( '%.6F', $mt ) ); $b = micro_time_precise_date_time_immutable( $mt ); $format = 'Y-m-d H:i:s.u'; var_dump( $a->format( $format ) ); var_dump( $b->format( $format ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cQtmk
function name:  (null)
number of ops:  34
compiled vars:  !0 = $mt, !1 = $a, !2 = $b, !3 = $format
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'date_default_timezone_set'
          1        SEND_VAL                                                 'UTC'
          2        DO_ICALL                                                 
   13     3        INIT_FCALL                                               'microtime'
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !0, $5
   15     7        INIT_STATIC_METHOD_CALL                                  'DateTimeImmutable', 'createFromFormat'
          8        SEND_VAL                                                 'U.u'
          9        INIT_FCALL                                               'sprintf'
         10        SEND_VAL                                                 '%25.6F'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $7      
         13        SEND_VAR                                                 $7
         14        DO_FCALL                                      0  $8      
         15        ASSIGN                                                   !1, $8
   16    16        INIT_FCALL                                               'micro_time_precise_date_time_immutable'
         17        SEND_VAR                                                 !0
         18        DO_FCALL                                      0  $10     
         19        ASSIGN                                                   !2, $10
   18    20        ASSIGN                                                   !3, 'Y-m-d+H%3Ai%3As.u'
   19    21        INIT_FCALL                                               'var_dump'
         22        INIT_METHOD_CALL                                         !1, 'format'
         23        SEND_VAR_EX                                              !3
         24        DO_FCALL                                      0  $13     
         25        SEND_VAR                                                 $13
         26        DO_ICALL                                                 
   20    27        INIT_FCALL                                               'var_dump'
         28        INIT_METHOD_CALL                                         !2, 'format'
         29        SEND_VAR_EX                                              !3
         30        DO_FCALL                                      0  $15     
         31        SEND_VAR                                                 $15
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Function micro_time_precise_date_time_immutable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cQtmk
function name:  micro_time_precise_date_time_immutable
number of ops:  24
compiled vars:  !0 = $microTime, !1 = $timestamp, !2 = $u
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'floor'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $3      
          4        CAST                                          4  ~4      $3
          5        ASSIGN                                                   !1, ~4
    8     6        INIT_FCALL                                               'sprintf'
          7        SEND_VAL                                                 '%2506d'
          8        SUB                                              ~6      !0, !1
          9        MUL                                              ~7      ~6, 1000000
         10        SEND_VAL                                                 ~7
         11        DO_ICALL                                         $8      
         12        ASSIGN                                                   !2, $8
   10    13        INIT_STATIC_METHOD_CALL                                  'DateTimeImmutable', 'createFromFormat'
         14        SEND_VAL                                                 'Y-m-d+H%3Ai%3As.u'
         15        INIT_FCALL                                               'date'
         16        CONCAT                                           ~10     'Y-m-d+H%3Ai%3As.', !2
         17        SEND_VAL                                                 ~10
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                         $11     
         20        SEND_VAR                                                 $11
         21        DO_FCALL                                      0  $12     
         22      > RETURN                                                   $12
   11    23*     > RETURN                                                   null

End of function micro_time_precise_date_time_immutable

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.42 ms | 1015 KiB | 20 Q