Quick actions

cmd+k|ctrl+k

Navigation

Languages

build-version-parse

Snippet info

Language

Php

Visibility

public

Author

ovidiugabriel

Created

2017-12-28T20:57:39Z

Updated

2017-12-28T21:07:43Z

<?php

error_reporting(E_ALL);

$t = "[.\Getts.cpp:WinMain:142] BUILD_VERSION: 28_11_17__18_11  c97c9a0530dc96a3f895aacabf60f176d4fd6005";


function extract_build_version($text) {
    if (preg_match('/BUILD_VERSION:\s*([0-9]{2})_([0-9]{2})_([0-9]{2})__([0-9]{2})_([0-9]{2}) /', $text, $match)) {
        list ($_, $day, $month, $year, $hour, $minute) = $match;
    
        $dateTime = new DateTime();
        $dateTime->setDate(  2000 + $year ,  $month ,  $day );
        $dateTime->setTime((int) $hour, (int) $minute);
        $dateTime->setTimezone(new DateTimeZone('Europe/Bucharest') );
        
        return $dateTime;
    }
}


$vers = extract_build_version($t);
print_r($vers);
INFO