Str_replace replaces every occurence

This commit is contained in:
Jeroen De Meerleer 2019-01-18 22:28:03 +01:00
parent 584492f5f4
commit 2d4bc8805a
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6

View File

@ -290,17 +290,24 @@ class Sws
private static function ReadHexData(String $data) private static function ReadHexData(String $data)
{ {
$hex = implode(unpack("H*", $data)); $hex = implode(unpack("H*", $data));
$hex = implode(array_reverse(str_split($hex, 2))); $hex = array_reverse(str_split($hex, 2));
$hex = str_replace("00", "", $hex);
foreach ($hex as $key=>$item) {
if ($item == "00") {
$hex[$key] = "";
} else {
break;
}
}
$hex = implode($hex);
return $hex; return $hex;
} }
private static function UIntToTimestamp($date) private static function UIntToTimestamp($date)
{ {
//echo $date;
$curyear = date('Y'); $curyear = date('Y');
$yearoffset = $curyear - self::PT_PASTOFFSET; $yearoffset = $curyear - self::PT_PASTOFFSET;
//$yearoffset = 100;
// Day // Day
$day = $date % self::PT_DAYFACTOR; $day = $date % self::PT_DAYFACTOR;
@ -320,7 +327,6 @@ class Sws
$concat = $month . '/' . $day . '/' . intval($year); $concat = $month . '/' . $day . '/' . intval($year);
$format = 'm/d/Y'; $format = 'm/d/Y';
echo $concat;
return \DateTime::createFromFormat($format, $concat); return \DateTime::createFromFormat($format, $concat);
} }