3v4l.org

run code in 300+ PHP versions simultaneously
<?php function parseDate($dateValue) { $dateFormats = array( 'D, d M y H:i:s T', 'D, d M Y H:i:s T', 'D, d-M-y H:i:s T', 'D, d-M-Y H:i:s T', 'D, d-m-y H:i:s T', 'D, d-m-Y H:i:s T', 'D M j G:i:s Y', 'D M d H:i:s Y T', ); foreach ($dateFormats as $dateFormat) { if (false !== $date = \DateTime::createFromFormat($dateFormat, $dateValue, new \DateTimeZone('GMT'))) { return $date; } } return date_create($dateValue, new \DateTimeZone('GMT')); } $dates = array( array('Friday, 31-Jul-20 08:49:37 GMT', 'Friday, 31-Jul-2020 08:49:37 GMT'), array('Fri Jul 31 08:49:37 2020', 'Friday, 31-Jul-2020 08:49:37 GMT'), ); foreach ($dates as $date) { echo parseDate($date[0])->format(\DateTime::COOKIE) . "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 13
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 13
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/VpvRp
function name:  (null)
number of ops:  15
compiled vars:  !0 = $dates, !1 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   ASSIGN                                                   !0, <array>
   28     1      > FE_RESET_R                                       $3      !0, ->13
          2    > > FE_FETCH_R                                               $3, !1, ->13
   29     3    >   INIT_FCALL                                               'parsedate'
          4        FETCH_DIM_R                                      ~4      !1, 0
          5        SEND_VAL                                                 ~4
          6        DO_FCALL                                      0  $5      
          7        INIT_METHOD_CALL                                         $5, 'format'
          8        SEND_VAL_EX                                              'l%2C+d-M-Y+H%3Ai%3As+T'
          9        DO_FCALL                                      0  $6      
         10        CONCAT                                           ~7      $6, '%0A'
         11        ECHO                                                     ~7
   28    12      > JMP                                                      ->2
         13    >   FE_FREE                                                  $3
   30    14      > RETURN                                                   1

Function parsedate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 18
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 18
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/VpvRp
function name:  parseDate
number of ops:  28
compiled vars:  !0 = $dateValue, !1 = $dateFormats, !2 = $dateFormat, !3 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, <array>
   15     2      > FE_RESET_R                                       $5      !1, ->18
          3    > > FE_FETCH_R                                               $5, !2, ->18
   16     4    >   INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
          5        SEND_VAR                                                 !2
          6        SEND_VAR                                                 !0
          7        NEW                                              $6      'DateTimeZone'
          8        SEND_VAL_EX                                              'GMT'
          9        DO_FCALL                                      0          
         10        SEND_VAR                                                 $6
         11        DO_FCALL                                      0  $8      
         12        ASSIGN                                           ~9      !3, $8
         13        TYPE_CHECK                                  1018          ~9
         14      > JMPZ                                                     ~10, ->17
   17    15    >   FE_FREE                                                  $5
         16      > RETURN                                                   !3
   15    17    > > JMP                                                      ->3
         18    >   FE_FREE                                                  $5
   21    19        INIT_FCALL                                               'date_create'
         20        SEND_VAR                                                 !0
         21        NEW                                              $11     'DateTimeZone'
         22        SEND_VAL_EX                                              'GMT'
         23        DO_FCALL                                      0          
         24        SEND_VAR                                                 $11
         25        DO_ICALL                                         $13     
         26      > RETURN                                                   $13
   22    27*     > RETURN                                                   null

End of function parsedate

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.23 ms | 992 KiB | 15 Q