3v4l.org

run code in 300+ PHP versions simultaneously
<?php $inputDate = "5/30/18"; $formatter = new IntlDateFormatter('en-US', IntlDateFormatter::SHORT, IntlDateFormatter::NONE, 'Europe/Berlin'); $timestamp = $formatter->parse($inputDate); print "Using date:\n"; print "Timestamp: {$timestamp}\n"; print "Formatted: ". date(\DateTime::ATOM ." e", $timestamp) ."\n"; print "MySQL: ". date("Y-m-d H:i:s", $timestamp) ."\n"; print "\n\nUsing DateTime(Immutable):\n"; $dt = \DateTimeImmutable::createFromFormat("!U", $timestamp); print "Formatted: ". $dt->format(\DateTime::ATOM ." e") ."\n"; print "MySQL: ". $dt->format("Y-m-d H:i:s") ."\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z2oBr
function name:  (null)
number of ops:  52
compiled vars:  !0 = $inputDate, !1 = $formatter, !2 = $timestamp, !3 = $dt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '5%2F30%2F18'
    4     1        NEW                                              $5      'IntlDateFormatter'
          2        SEND_VAL_EX                                              'en-US'
          3        FETCH_CLASS_CONSTANT                             ~6      'IntlDateFormatter', 'SHORT'
          4        SEND_VAL_EX                                              ~6
          5        FETCH_CLASS_CONSTANT                             ~7      'IntlDateFormatter', 'NONE'
          6        SEND_VAL_EX                                              ~7
          7        SEND_VAL_EX                                              'Europe%2FBerlin'
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !1, $5
    5    10        INIT_METHOD_CALL                                         !1, 'parse'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0  $10     
         13        ASSIGN                                                   !2, $10
    7    14        ECHO                                                     'Using+date%3A%0A'
    8    15        ROPE_INIT                                     3  ~13     'Timestamp%3A+'
         16        ROPE_ADD                                      1  ~13     ~13, !2
         17        ROPE_END                                      2  ~12     ~13, '%0A'
         18        ECHO                                                     ~12
    9    19        INIT_FCALL                                               'date'
         20        SEND_VAL                                                 'Y-m-d%5CTH%3Ai%3AsP+e'
         21        SEND_VAR                                                 !2
         22        DO_ICALL                                         $15     
         23        CONCAT                                           ~16     'Formatted%3A+', $15
         24        CONCAT                                           ~17     ~16, '%0A'
         25        ECHO                                                     ~17
   10    26        INIT_FCALL                                               'date'
         27        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                         $18     
         30        CONCAT                                           ~19     'MySQL%3A+', $18
         31        CONCAT                                           ~20     ~19, '%0A'
         32        ECHO                                                     ~20
   12    33        ECHO                                                     '%0A%0AUsing+DateTime%28Immutable%29%3A%0A'
   13    34        INIT_STATIC_METHOD_CALL                                  'DateTimeImmutable', 'createFromFormat'
         35        SEND_VAL                                                 '%21U'
         36        SEND_VAR                                                 !2
         37        DO_FCALL                                      0  $21     
         38        ASSIGN                                                   !3, $21
   14    39        INIT_METHOD_CALL                                         !3, 'format'
         40        SEND_VAL_EX                                              'Y-m-d%5CTH%3Ai%3AsP+e'
         41        DO_FCALL                                      0  $23     
         42        CONCAT                                           ~24     'Formatted%3A+', $23
         43        CONCAT                                           ~25     ~24, '%0A'
         44        ECHO                                                     ~25
   15    45        INIT_METHOD_CALL                                         !3, 'format'
         46        SEND_VAL_EX                                              'Y-m-d+H%3Ai%3As'
         47        DO_FCALL                                      0  $26     
         48        CONCAT                                           ~27     'MySQL%3A+', $26
         49        CONCAT                                           ~28     ~27, '%0A'
         50        ECHO                                                     ~28
         51      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
180.29 ms | 1400 KiB | 15 Q